Commit a881ffad authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 389d54da 36d1d908
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
mouseOver: { dropdownOpen: {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
...@@ -92,8 +92,9 @@ export default { ...@@ -92,8 +92,9 @@ export default {
<new-dropdown <new-dropdown
:type="file.type" :type="file.type"
:path="file.path" :path="file.path"
:mouse-over="mouseOver" :is-open="dropdownOpen"
class="prepend-left-8" class="prepend-left-8"
v-on="$listeners"
/> />
</div> </div>
</template> </template>
...@@ -21,38 +21,29 @@ export default { ...@@ -21,38 +21,29 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
mouseOver: { isOpen: {
type: Boolean, type: Boolean,
required: true, required: false,
default: false,
}, },
}, },
data() {
return {
dropdownOpen: false,
};
},
watch: { watch: {
dropdownOpen() { isOpen() {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.dropdownMenu.scrollIntoView({ this.$refs.dropdownMenu.scrollIntoView({
block: 'nearest', block: 'nearest',
}); });
}); });
}, },
mouseOver() {
if (!this.mouseOver) {
this.dropdownOpen = false;
}
},
}, },
methods: { methods: {
...mapActions(['createTempEntry', 'openNewEntryModal', 'deleteEntry']), ...mapActions(['createTempEntry', 'openNewEntryModal', 'deleteEntry']),
createNewItem(type) { createNewItem(type) {
this.openNewEntryModal({ type, path: this.path }); this.openNewEntryModal({ type, path: this.path });
this.dropdownOpen = false; this.$emit('toggle', false);
}, },
openDropdown() { openDropdown() {
this.dropdownOpen = !this.dropdownOpen; this.$emit('toggle', !this.isOpen);
}, },
}, },
modalTypes, modalTypes,
...@@ -63,7 +54,7 @@ export default { ...@@ -63,7 +54,7 @@ export default {
<div class="ide-new-btn"> <div class="ide-new-btn">
<div <div
:class="{ :class="{
show: dropdownOpen, show: isOpen,
}" }"
class="dropdown d-flex" class="dropdown d-flex"
> >
......
...@@ -4,10 +4,11 @@ import service from '../../services'; ...@@ -4,10 +4,11 @@ import service from '../../services';
import * as types from '../mutation_types'; import * as types from '../mutation_types';
import { activityBarViews } from '../../constants'; import { activityBarViews } from '../../constants';
export const getMergeRequestsForBranch = ({ commit }, { projectId, branchId } = {}) => export const getMergeRequestsForBranch = ({ commit, state }, { projectId, branchId } = {}) =>
service service
.getProjectMergeRequests(`${projectId}`, { .getProjectMergeRequests(`${projectId}`, {
source_branch: branchId, source_branch: branchId,
source_project_id: state.projects[projectId].id,
order_by: 'created_at', order_by: 'created_at',
per_page: 1, per_page: 1,
}) })
......
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
}, },
data() { data() {
return { return {
mouseOver: false, dropdownOpen: false,
}; };
}, },
computed: { computed: {
...@@ -123,8 +123,8 @@ export default { ...@@ -123,8 +123,8 @@ export default {
return this.$router.currentRoute.path === `/project${this.file.url}`; return this.$router.currentRoute.path === `/project${this.file.url}`;
}, },
toggleHover(over) { toggleDropdown(val) {
this.mouseOver = over; this.dropdownOpen = val;
}, },
}, },
}; };
...@@ -140,8 +140,7 @@ export default { ...@@ -140,8 +140,7 @@ export default {
class="file-row" class="file-row"
role="button" role="button"
@click="clickFile" @click="clickFile"
@mouseover="toggleHover(true)" @mouseleave="toggleDropdown(false)"
@mouseout="toggleHover(false)"
> >
<div class="file-row-name-container"> <div class="file-row-name-container">
<span ref="textOutput" :style="levelIndentation" class="file-row-name str-truncated"> <span ref="textOutput" :style="levelIndentation" class="file-row-name str-truncated">
...@@ -160,7 +159,8 @@ export default { ...@@ -160,7 +159,8 @@ export default {
:is="extraComponent" :is="extraComponent"
v-if="extraComponent && !(hideExtraOnTree && file.type === 'tree')" v-if="extraComponent && !(hideExtraOnTree && file.type === 'tree')"
:file="file" :file="file"
:mouse-over="mouseOver" :dropdown-open="dropdownOpen"
@toggle="toggleDropdown($event)"
/> />
</div> </div>
</div> </div>
......
...@@ -167,6 +167,23 @@ ...@@ -167,6 +167,23 @@
} }
} }
.frame {
top: 0;
right: 0;
&.old-diff {
/* only for commit / compare view */
position: absolute;
}
&.deleted {
margin: 0;
display: block;
top: 13px;
right: 7px;
}
}
.swipe-bar { .swipe-bar {
display: block; display: block;
height: 100%; height: 100%;
......
...@@ -40,7 +40,8 @@ class MergeRequestsFinder < IssuableFinder ...@@ -40,7 +40,8 @@ class MergeRequestsFinder < IssuableFinder
items = by_commit(super) items = by_commit(super)
items = by_source_branch(items) items = by_source_branch(items)
items = by_wip(items) items = by_wip(items)
by_target_branch(items) items = by_target_branch(items)
by_source_project_id(items)
end end
private private
...@@ -74,6 +75,16 @@ class MergeRequestsFinder < IssuableFinder ...@@ -74,6 +75,16 @@ class MergeRequestsFinder < IssuableFinder
items.where(target_branch: target_branch) items.where(target_branch: target_branch)
end end
def source_project_id
@source_project_id ||= params[:source_project_id].presence
end
def by_source_project_id(items)
return items unless source_project_id
items.where(source_project_id: source_project_id)
end
def by_wip(items) def by_wip(items)
if params[:wip] == 'yes' if params[:wip] == 'yes'
items.where(wip_match(items.arel_table)) items.where(wip_match(items.arel_table))
......
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
.swipe.view.hide .swipe.view.hide
.swipe-frame .swipe-frame
.frame.deleted .frame.deleted.old-diff
= image_tag(old_blob_raw_url, alt: diff_file.old_path, lazy: false) = image_tag(old_blob_raw_url, alt: diff_file.old_path, lazy: false)
.swipe-wrap.left-oriented .swipe-wrap.left-oriented
= render partial: "projects/diffs/image_diff_frame", locals: { class_name: "added js-image-frame #{class_name}", position: position, note_type: DiffNote.name, image_path: blob_raw_url, alt: diff_file.new_path } = render partial: "projects/diffs/image_diff_frame", locals: { class_name: "added old-diff js-image-frame #{class_name}", position: position, note_type: DiffNote.name, image_path: blob_raw_url, alt: diff_file.new_path }
%span.swipe-bar %span.swipe-bar
%span.top-handle %span.top-handle
%span.bottom-handle %span.bottom-handle
......
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
.image.js-single-image{ data: diff_view_data } .image.js-single-image{ data: diff_view_data }
.wrap .wrap
- single_class_name = diff_file.deleted_file? ? 'deleted' : 'added' - single_class_name = diff_file.deleted_file? ? 'deleted' : 'added'
= render partial: "projects/diffs/image_diff_frame", locals: { class_name: "#{single_class_name} #{class_name} js-image-frame", position: position, note_type: DiffNote.name, image_path: blob_raw_url, alt: diff_file.file_path } = render partial: "projects/diffs/image_diff_frame", locals: { class_name: "#{single_class_name} #{class_name} old-diff js-image-frame", position: position, note_type: DiffNote.name, image_path: blob_raw_url, alt: diff_file.file_path }
%p.image-info= number_to_human_size(blob.size) %p.image-info= number_to_human_size(blob.size)
---
title: "Fix image diff swipe view on commit and compare pages"
merge_request: 26968
author: ftab
type: fixed
\ No newline at end of file
---
title: Fix IDE detection of MR from fork with same branch name
merge_request: 26986
author:
type: fixed
...@@ -113,6 +113,7 @@ module API ...@@ -113,6 +113,7 @@ module API
desc: 'Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`' desc: 'Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`'
optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji' optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji'
optional :source_branch, type: String, desc: 'Return merge requests with the given source branch' optional :source_branch, type: String, desc: 'Return merge requests with the given source branch'
optional :source_project_id, type: Integer, desc: 'Return merge requests with the given source project id'
optional :target_branch, type: String, desc: 'Return merge requests with the given target branch' optional :target_branch, type: String, desc: 'Return merge requests with the given target branch'
optional :search, type: String, desc: 'Search merge requests for text present in the title, description, or any combination of these' optional :search, type: String, desc: 'Search merge requests for text present in the title, description, or any combination of these'
optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma' optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma'
......
...@@ -83,6 +83,14 @@ describe MergeRequestsFinder do ...@@ -83,6 +83,14 @@ describe MergeRequestsFinder do
expect(merge_requests).to contain_exactly(merge_request2) expect(merge_requests).to contain_exactly(merge_request2)
end end
it 'filters by source project id' do
params = { source_project_id: merge_request2.source_project_id }
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request1, merge_request2, merge_request3)
end
it 'filters by state' do it 'filters by state' do
params = { state: 'locked' } params = { state: 'locked' }
......
...@@ -20,7 +20,7 @@ describe('IDE extra file row component', () => { ...@@ -20,7 +20,7 @@ describe('IDE extra file row component', () => {
file: { file: {
...file('test'), ...file('test'),
}, },
mouseOver: false, dropdownOpen: false,
}); });
spyOnProperty(vm, 'getUnstagedFilesCountForPath').and.returnValue(() => unstagedFilesCount); spyOnProperty(vm, 'getUnstagedFilesCountForPath').and.returnValue(() => unstagedFilesCount);
......
...@@ -56,11 +56,11 @@ describe('new dropdown component', () => { ...@@ -56,11 +56,11 @@ describe('new dropdown component', () => {
}); });
}); });
describe('dropdownOpen', () => { describe('isOpen', () => {
it('scrolls dropdown into view', done => { it('scrolls dropdown into view', done => {
spyOn(vm.$refs.dropdownMenu, 'scrollIntoView'); spyOn(vm.$refs.dropdownMenu, 'scrollIntoView');
vm.dropdownOpen = true; vm.isOpen = true;
setTimeout(() => { setTimeout(() => {
expect(vm.$refs.dropdownMenu.scrollIntoView).toHaveBeenCalledWith({ expect(vm.$refs.dropdownMenu.scrollIntoView).toHaveBeenCalledWith({
......
import Vue from 'vue'; import Vue from 'vue';
import FileRow from '~/vue_shared/components/file_row.vue'; import FileRow from '~/vue_shared/components/file_row.vue';
import FileRowExtra from '~/ide/components/file_row_extra.vue';
import { file } from 'spec/ide/helpers'; import { file } from 'spec/ide/helpers';
import mountComponent from '../../helpers/vue_mount_component_helper'; import mountComponent from '../../helpers/vue_mount_component_helper';
...@@ -16,6 +17,10 @@ describe('File row component', () => { ...@@ -16,6 +17,10 @@ describe('File row component', () => {
vm.$destroy(); vm.$destroy();
}); });
const findNewDropdown = () => vm.$el.querySelector('.ide-new-btn .dropdown');
const findNewDropdownButton = () => vm.$el.querySelector('.ide-new-btn .dropdown button');
const findFileRow = () => vm.$el.querySelector('.file-row');
it('renders name', () => { it('renders name', () => {
createComponent({ createComponent({
file: file('t4'), file: file('t4'),
...@@ -84,4 +89,59 @@ describe('File row component', () => { ...@@ -84,4 +89,59 @@ describe('File row component', () => {
expect(vm.$el.querySelector('.js-file-row-header')).not.toBe(null); expect(vm.$el.querySelector('.js-file-row-header')).not.toBe(null);
}); });
describe('new dropdown', () => {
beforeEach(() => {
createComponent({
file: file('t5'),
level: 1,
extraComponent: FileRowExtra,
});
});
it('renders in extra component', () => {
expect(findNewDropdown()).not.toBe(null);
});
it('is hidden at start', () => {
expect(findNewDropdown()).not.toHaveClass('show');
});
it('is opened when button is clicked', done => {
expect(vm.dropdownOpen).toBe(false);
findNewDropdownButton().dispatchEvent(new Event('click'));
vm.$nextTick()
.then(() => {
expect(vm.dropdownOpen).toBe(true);
expect(findNewDropdown()).toHaveClass('show');
})
.then(done)
.catch(done.fail);
});
describe('when opened', () => {
beforeEach(() => {
vm.dropdownOpen = true;
});
it('stays open when button triggers mouseout', () => {
findNewDropdownButton().dispatchEvent(new Event('mouseout'));
expect(vm.dropdownOpen).toBe(true);
});
it('stays open when button triggers mouseleave', () => {
findNewDropdownButton().dispatchEvent(new Event('mouseleave'));
expect(vm.dropdownOpen).toBe(true);
});
it('closes when row triggers mouseleave', () => {
findFileRow().dispatchEvent(new Event('mouseleave'));
expect(vm.dropdownOpen).toBe(false);
});
});
});
}); });
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