Commit 8b2046d4 authored by Simon Knox's avatar Simon Knox

Merge branch '2518-saved-configuration-for-issue-board' of...

Merge branch '2518-saved-configuration-for-issue-board' of gitlab.com:gitlab-org/gitlab-ee into 2518-saved-configuration-for-issue-board
parents 6d26fcdc 6977b272
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
this.error = false; this.error = false;
// TODO: add board labels const board = Store.state.currentBoard;
const labels = this.list.label ? [this.list.label] : []; const labels = this.list.label ? [this.list.label] : [];
const issue = new ListIssue({ const issue = new ListIssue({
title: this.title, title: this.title,
...@@ -52,8 +52,10 @@ export default { ...@@ -52,8 +52,10 @@ export default {
project_id: this.selectedProject.id, project_id: this.selectedProject.id,
}); });
if (Store.state.currentBoard) { if (board) {
issue.milestone_id = Store.state.currentBoard.milestone_id; issue.assignees = [board.assignee];
issue.labels = _.sortBy(_.uniq([...labels, ...board.labels], label => label.id),
'title');
} }
eventHub.$emit(`scroll-board-list-${this.list.id}`); eventHub.$emit(`scroll-board-list-${this.list.id}`);
......
...@@ -30,24 +30,42 @@ gl.issueBoards.RemoveIssueBtn = Vue.extend({ ...@@ -30,24 +30,42 @@ gl.issueBoards.RemoveIssueBtn = Vue.extend({
}, },
methods: { methods: {
removeIssue() { removeIssue() {
const board = Store.state.currentBoard;
const issue = this.issue; const issue = this.issue;
const lists = issue.getLists(); const lists = issue.getLists();
const boardLabelIds = board.labels.map(label => label.id);
const listLabelIds = lists.map(list => list.label.id); const listLabelIds = lists.map(list => list.label.id);
let labelIds = this.issue.labels
let labelIds = issue.labels
.map(label => label.id) .map(label => label.id)
.filter(id => !listLabelIds.includes(id)); .filter(id => !listLabelIds.includes(id))
.filter(id => !boardLabelIds.includes(id));
if (labelIds.length === 0) { if (labelIds.length === 0) {
labelIds = ['']; labelIds = [''];
} }
let assigneeIds = issue.assignees
.map(assignee => assignee.id)
.filter(id => id !== board.assignee_id);
if (assigneeIds.length === 0) {
assigneeIds = ['0'];
}
const data = { const data = {
issue: { issue: {
label_ids: labelIds, label_ids: labelIds,
assignee_ids: assigneeIds
}, },
}; };
if (Store.state.currentBoard.milestone_id) {
if (board.milestone_id) {
data.issue.milestone_id = -1; data.issue.milestone_id = -1;
} }
if (board.weight) {
data.issue.weight = null;
}
// Post the remove data // Post the remove data
Vue.http.patch(this.updateUrl, data).catch(() => { Vue.http.patch(this.updateUrl, data).catch(() => {
new Flash('Failed to remove issue from board, please try again.', 'alert'); new Flash('Failed to remove issue from board, please try again.', 'alert');
......
...@@ -10,11 +10,18 @@ module Boards ...@@ -10,11 +10,18 @@ module Boards
end end
def execute def execute
create_issue(params.merge(label_ids: [list.label_id])) create_issue(creation_params)
end end
private private
def creation_params
params.merge(label_ids: [list.label_id, *board.label_ids],
weight: board.weight,
milestone_id: board.milestone_id,
assignee_ids: [board.assignee_id])
end
def board def board
@board ||= parent.boards.find(params.delete(:board_id)) @board ||= parent.boards.find(params.delete(:board_id))
end end
......
module Boards module Boards
class UpdateService < Boards::BaseService class UpdateService < Boards::BaseService
def execute(board) def execute(board)
params.delete(:milestone_id) unless parent.feature_available?(:scoped_issue_board) unless parent.feature_available?(:scoped_issue_board)
params.delete(:milestone_id)
params.delete(:assignee_id)
params.delete(:label_ids)
params.delete(:weight)
end
board.update(params) board.update(params)
end end
......
...@@ -5,6 +5,10 @@ module EE ...@@ -5,6 +5,10 @@ module EE
end end
def board_data def board_data
show_feature_promotion = (@project && show_promotions? &&
(!@project.feature_available?(:multiple_issue_boards) ||
!@project.feature_available?(:scoped_issue_board) ||
!@project.feature_available?(:issue_board_focus_mode))).to_s
data = { data = {
board_milestone_title: board&.milestone&.title, board_milestone_title: board&.milestone&.title,
board_author_username: board&.author&.username, board_author_username: board&.author&.username,
...@@ -13,7 +17,7 @@ module EE ...@@ -13,7 +17,7 @@ module EE
labels: board&.labels.to_json(only: [:id, :title, :color] ), labels: board&.labels.to_json(only: [:id, :title, :color] ),
board_weight: board&.weight, board_weight: board&.weight,
focus_mode_available: parent.feature_available?(:issue_board_focus_mode).to_s, focus_mode_available: parent.feature_available?(:issue_board_focus_mode).to_s,
show_promotion: (@project && show_promotions? && (!@project.feature_available?(:multiple_issue_boards) || !@project.feature_available?(:scoped_issue_board) || !@project.feature_available?(:issue_board_focus_mode))).to_s show_promotion: show_feature_promotion
} }
super.merge(data) super.merge(data)
......
...@@ -29,5 +29,23 @@ describe Boards::Issues::CreateService do ...@@ -29,5 +29,23 @@ describe Boards::Issues::CreateService do
expect(issue.labels).to eq [label] expect(issue.labels).to eq [label]
end end
it 'adds the board assignee, weight, labels and milestone to the issue' do
board_assignee = create(:user)
project.team << [board_assignee, :developer]
board_milestone = create(:milestone, project: project)
board_label = create(:label, project: project)
board.update!(assignee: board_assignee,
milestone: board_milestone,
label_ids: [board_label.id],
weight: 4)
issue = service.execute
expect(issue.assignees).to eq([board_assignee])
expect(issue.weight).to eq(board.weight)
expect(issue.milestone).to eq(board_milestone)
expect(issue.labels).to contain_exactly(label, board_label)
end
end end
end end
...@@ -25,7 +25,7 @@ describe Boards::UpdateService do ...@@ -25,7 +25,7 @@ describe Boards::UpdateService do
expect(service.execute(board)).to eq false expect(service.execute(board)).to eq false
end end
it 'udpates the milestone with issue board milestones enabled' do it 'updates the milestone with issue board milestones enabled' do
stub_licensed_features(scoped_issue_board: true) stub_licensed_features(scoped_issue_board: true)
milestone = create(:milestone, project: project) milestone = create(:milestone, project: project)
...@@ -35,14 +35,14 @@ describe Boards::UpdateService do ...@@ -35,14 +35,14 @@ describe Boards::UpdateService do
expect(board.reload.milestone).to eq(milestone) expect(board.reload.milestone).to eq(milestone)
end end
it 'udpates the milestone with the issue board milestones feature enabled' do it 'filters unpermitted params when scoped issue board is not enabled' do
stub_licensed_features(scoped_issue_board: false) stub_licensed_features(scoped_issue_board: false)
milestone = create(:milestone, project: project) params = { milestone_id: double, assignee_id: double, label_ids: double, weight: double }
service = described_class.new(project, double, milestone_id: milestone.id) expect(board).to receive(:update).with({})
service.execute(board)
expect(board.reload.milestone).to be_nil service = described_class.new(project, double, params)
service.execute(board)
end end
end end
end end
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