Commit 1c01dc27 authored by Valery Sizov's avatar Valery Sizov

Merge branch 'multiple_assignees_review' of gitlab.com:gitlab-org/gitlab-ee...

Merge branch 'multiple_assignees_review' of gitlab.com:gitlab-org/gitlab-ee into multiple_assignees_review_upstream
parents ae72d3d7 f82c8714
......@@ -446,15 +446,34 @@ GitLabDropdown = (function() {
}
};
GitLabDropdown.prototype.filteredFullData = function() {
return this.fullData.filter(r => typeof r === 'object'
&& !Object.prototype.hasOwnProperty.call(r, 'beforeDivider')
&& !Object.prototype.hasOwnProperty.call(r, 'header')
);
};
GitLabDropdown.prototype.opened = function(e) {
var contentHtml;
this.resetRows();
this.addArrowKeyEvent();
const dropdownToggle = this.dropdown.find('.dropdown-menu-toggle');
const hasFilterBulkUpdate = dropdownToggle.hasClass('js-filter-bulk-update');
const hasMultiSelect = dropdownToggle.hasClass('js-multiselect');
// Makes indeterminate items effective
if (this.fullData && this.dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')) {
if (this.fullData && hasFilterBulkUpdate) {
this.parseData(this.fullData);
}
// Process the data to make sure rendered data
// matches the correct layout
if (this.fullData && hasMultiSelect && this.options.processData) {
const inputValue = this.filterInput.val();
this.options.processData.call(this.options, inputValue, this.filteredFullData(), this.parseData.bind(this));
}
contentHtml = $('.dropdown-content', this.dropdown).html();
if (this.remote && contentHtml === "") {
this.remote.execute();
......
......@@ -88,7 +88,10 @@
const formData = {
update: {
state_event: this.form.find('input[name="update[state_event]"]').val(),
// For Merge Requests
assignee_id: this.form.find('input[name="update[assignee_id]"]').val(),
// For Issues
assignee_ids: [this.form.find('input[name="update[assignee_ids][]"]').val()],
milestone_id: this.form.find('input[name="update[milestone_id]"]').val(),
issuable_ids: this.form.find('input[name="update[issuable_ids]"]').val(),
subscription_event: this.form.find('input[name="update[subscription_event]"]').val(),
......
......@@ -279,10 +279,7 @@ import eventHub from './sidebar/event_hub';
if (this.multiSelect && inputValue === '') {
// Remove non-users from the fullData array
const users = glDropdown.fullData.filter(r => typeof r === 'object'
&& !Object.prototype.hasOwnProperty.call(r, 'beforeDivider')
&& !Object.prototype.hasOwnProperty.call(r, 'header')
);
const users = glDropdown.filteredFullData();
const callback = glDropdown.parseData.bind(glDropdown);
// Update the data model
......
......@@ -585,16 +585,19 @@
vertical-align: text-top;
}
}
}
}
.avatar-counter {
display: inline-block;
vertical-align: middle;
min-width: 16px;
line-height: 14px;
height: 16px;
padding-left: 2px;
padding-right: 2px;
}
.issuable-list li,
.issue-info-container .controls {
.avatar-counter {
display: inline-block;
vertical-align: middle;
min-width: 16px;
line-height: 14px;
height: 16px;
padding-left: 2px;
padding-right: 2px;
}
}
......
......@@ -66,6 +66,7 @@ module IssuableActions
:milestone_id,
:state_event,
:subscription_event,
assignee_ids: [],
label_ids: [],
add_label_ids: [],
remove_label_ids: []
......
......@@ -147,8 +147,13 @@
%li
%a{ href: "#", data: { id: "close" } } Closed
.filter-item.inline
- if type == :issues
- field_name = "update[assignee_ids][]"
- else
- field_name = "update[assignee_id]"
= dropdown_tag("Assignee", options: { toggle_class: "js-user-search js-update-assignee js-filter-submit js-filter-bulk-update", title: "Assign to", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable",
placeholder: "Search authors", data: { first_user: (current_user.username if current_user), null_user: true, current_user: true, project_id: @project.id, field_name: "update[assignee_id]" } })
placeholder: "Search authors", data: { first_user: (current_user.username if current_user), null_user: true, current_user: true, project_id: @project.id, field_name: field_name } })
.filter-item.inline
= dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update', filter: true, dropdown_class: "dropdown-menu-selectable dropdown-menu-milestone", placeholder: "Search milestones", data: { show_no: true, field_name: "update[milestone_id]", project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), use_id: true } })
.filter-item.inline.labels-filter
......
......@@ -4,6 +4,7 @@ describe 'Issue Boards', feature: true, js: true do
include WaitForVueResource
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:project) { create(:empty_project, :public) }
let!(:milestone) { create(:milestone, project: project) }
let!(:development) { create(:label, project: project, name: 'Development') }
......@@ -20,6 +21,7 @@ describe 'Issue Boards', feature: true, js: true do
Timecop.freeze
project.team << [user, :master]
project.team.add_developer(user2)
login_as(user)
......@@ -101,6 +103,26 @@ describe 'Issue Boards', feature: true, js: true do
expect(card).to have_selector('.avatar')
end
it 'adds multiple assignees' do
click_card(card)
page.within('.assignee') do
click_link 'Edit'
wait_for_ajax
page.within('.dropdown-menu-user') do
click_link user.name
click_link user2.name
end
expect(page).to have_content(user.name)
expect(page).to have_content(user2.name)
end
expect(card.all('.avatar').length).to eq(2)
end
it 'removes the assignee' do
card_two = first('.board').find('.card:nth-child(2)')
click_card(card_two)
......@@ -112,10 +134,11 @@ describe 'Issue Boards', feature: true, js: true do
page.within('.dropdown-menu-user') do
click_link 'Unassigned'
wait_for_vue_resource
end
find('.dropdown-menu-toggle').click
wait_for_vue_resource
expect(page).to have_content('No assignee')
end
......@@ -128,7 +151,7 @@ describe 'Issue Boards', feature: true, js: true do
page.within(find('.assignee')) do
expect(page).to have_content('No assignee')
click_link 'assign yourself'
click_button 'assign yourself'
wait_for_vue_resource
......@@ -138,7 +161,7 @@ describe 'Issue Boards', feature: true, js: true do
expect(card).to have_selector('.avatar')
end
it 'resets assignee dropdown' do
it 'updates assignee dropdown' do
click_card(card)
page.within('.assignee') do
......@@ -162,7 +185,7 @@ describe 'Issue Boards', feature: true, js: true do
page.within('.assignee') do
click_link 'Edit'
expect(page).not_to have_selector('.is-active')
expect(page).to have_selector('.is-active')
end
end
end
......
......@@ -41,6 +41,21 @@ feature 'Issue Sidebar', feature: true do
expect(page).to have_content(user2.name)
end
end
it 'assigns yourself' do
find('.block.assignee .dropdown-menu-toggle').click
click_button 'assign yourself'
wait_for_ajax
find('.block.assignee .edit-link').click
page.within '.dropdown-menu-user' do
expect(page.find('.dropdown-header')).to be_visible
expect(page.find('.dropdown-menu-user-link.is-active')).to have_content(user.name)
end
end
end
context 'as a allowed user' do
......
......@@ -2,6 +2,7 @@
/* global BoardService */
/* global ListIssue */
import Vue from 'vue';
import '~/lib/utils/url_utility';
import '~/boards/models/issue';
import '~/boards/models/label';
......@@ -28,7 +29,12 @@ describe('Issue model', () => {
color: 'red',
description: 'testing'
}],
assignees: [],
assignees: [{
id: 1,
name: 'name',
username: 'username',
avatar_url: 'http://avatar_url',
}],
});
});
......@@ -81,6 +87,33 @@ describe('Issue model', () => {
expect(issue.labels.length).toBe(0);
});
it('adds assignee', () => {
issue.addAssignee({
id: 2,
name: 'Bruce Wayne',
username: 'batman',
avatar_url: 'http://batman',
});
expect(issue.assignees.length).toBe(2);
});
it('finds assignee', () => {
const assignee = issue.findAssignee(issue.assignees[0]);
expect(assignee).toBeDefined();
});
it('removes assignee', () => {
const assignee = issue.findAssignee(issue.assignees[0]);
issue.removeAssignee(assignee);
expect(issue.assignees.length).toBe(0);
});
it('removes all assignees', () => {
issue.removeAllAssignees();
expect(issue.assignees.length).toBe(0);
});
it('sets position to infinity if no position is stored', () => {
expect(issue.position).toBe(Infinity);
});
......@@ -97,4 +130,25 @@ describe('Issue model', () => {
expect(relativePositionIssue.position).toBe(1);
});
describe('update', () => {
it('passes assignee ids when there are assignees', (done) => {
spyOn(Vue.http, 'patch').and.callFake((url, data) => {
expect(data.issue.assignee_ids).toEqual([1]);
done();
});
issue.update('url');
});
it('passes assignee ids of [0] when there are no assignees', (done) => {
spyOn(Vue.http, 'patch').and.callFake((url, data) => {
expect(data.issue.assignee_ids).toEqual([0]);
done();
});
issue.removeAllAssignees();
issue.update('url');
});
});
});
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