Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Sanford <alex.sanford1@gmail.com>2017-04-28 15:11:53 +0300
committerSean McGivern <sean@mcgivern.me.uk>2017-04-28 15:11:53 +0300
commit85bb4d6b86bbfd3f5f6e98ac67394454ae81439e (patch)
tree932a57e588420fa71254cf119af9b35715d4596f /app/services
parentf2d637f78c9c2fe14d716e58339856dd318c31c0 (diff)
Add board_move slash command
Diffstat (limited to 'app/services')
-rw-r--r--app/services/boards/issues/move_service.rb2
-rw-r--r--app/services/slash_commands/interpret_service.rb22
2 files changed, 23 insertions, 1 deletions
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index d5735f13c1e..e73b1a4361a 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -61,7 +61,7 @@ module Boards
if moving_to_list.movable?
moving_from_list.label_id
else
- project.boards.joins(:lists).merge(List.movable).pluck(:label_id)
+ Label.on_project_boards(project.id).pluck(:label_id)
end
Array(label_ids).compact
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb
index 49d45ec9dbd..6aeebc26685 100644
--- a/app/services/slash_commands/interpret_service.rb
+++ b/app/services/slash_commands/interpret_service.rb
@@ -330,6 +330,28 @@ module SlashCommands
@updates[:target_branch] = branch_name if project.repository.branch_names.include?(branch_name)
end
+ desc 'Move issue from one column of the board to another'
+ params '~"Target column"'
+ condition do
+ issuable.is_a?(Issue) &&
+ current_user.can?(:"update_#{issuable.to_ability_name}", issuable) &&
+ issuable.project.boards.count == 1
+ end
+ command :board_move do |target_list_name|
+ label_ids = find_label_ids(target_list_name)
+
+ if label_ids.size == 1
+ label_id = label_ids.first
+
+ # Ensure this label corresponds to a list on the board
+ next unless Label.on_project_boards(issuable.project_id).where(id: label_id).exists?
+
+ @updates[:remove_label_ids] =
+ issuable.labels.on_project_boards(issuable.project_id).where.not(id: label_id).pluck(:id)
+ @updates[:add_label_ids] = [label_id]
+ end
+ end
+
def find_label_ids(labels_param)
label_ids_by_reference = extract_references(labels_param, :label).map(&:id)
labels_ids_by_name = LabelsFinder.new(current_user, project_id: project.id, name: labels_param.split).execute.select(:id)