summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-05-08 17:54:18 +0300
committerValery Sizov <valery@gitlab.com>2017-05-08 17:54:18 +0300
commite26a1c7ae5da5639ab39b36fabdd558725ca0f8d (patch)
treeacf7583a82a5903b9a78623b7216ff7ac2acf924
parent62b0eb2c0ba02d2a9c9515722dfcb7ec61b7fc6a (diff)
downloadgitlab-ce-temp1.tar.gz
temporary[ci skip]temp1
-rw-r--r--app/controllers/concerns/issuable_actions.rb14
-rw-r--r--app/helpers/issuables_helper.rb5
-rw-r--r--app/services/issuable/bulk_update_service.rb15
-rw-r--r--app/services/system_note_service.rb2
-rw-r--r--app/views/shared/issuable/_assignees.html.haml5
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml15
-rw-r--r--app/views/shared/issuable/form/_issue_assignee.html.haml9
-rw-r--r--doc/api/issues.md22
-rw-r--r--lib/api/helpers/common_helpers.rb8
-rw-r--r--spec/requests/api/issues_spec.rb2
-rw-r--r--spec/services/issuable/bulk_update_service_spec.rb4
11 files changed, 62 insertions, 39 deletions
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb
index b199f18da1e..3db5928c9a1 100644
--- a/app/controllers/concerns/issuable_actions.rb
+++ b/app/controllers/concerns/issuable_actions.rb
@@ -60,17 +60,25 @@ module IssuableActions
end
def bulk_update_params
- params.require(:update).permit(
+ permitted_keys = [
:issuable_ids,
:assignee_id,
:milestone_id,
:state_event,
:subscription_event,
- assignee_ids: [],
label_ids: [],
add_label_ids: [],
remove_label_ids: []
- )
+ ]
+
+ if resource_name == 'issue'
+ permitted_keys << { assignee_ids: [] },
+ else
+ permitted_keys.unshift(:assignee_id)
+ end
+
+
+ params.require(:update).permit(permitted_keys)
end
def resource_name
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index 7656929efe7..d110287ea55 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -64,9 +64,10 @@ module IssuablesHelper
end
def users_dropdown_label(selected_users)
- if selected_users.length == 0
+ case selected_users.length
+ when 0
"Unassigned"
- elsif selected_users.length == 1
+ when 1
selected_users[0].name
else
"#{selected_users[0].name} + #{selected_users.length - 1} more"
diff --git a/app/services/issuable/bulk_update_service.rb b/app/services/issuable/bulk_update_service.rb
index 40ff9b8b867..840eb4c53c0 100644
--- a/app/services/issuable/bulk_update_service.rb
+++ b/app/services/issuable/bulk_update_service.rb
@@ -7,7 +7,7 @@ module Issuable
ids = params.delete(:issuable_ids).split(",")
items = model_class.where(id: ids)
- %i(state_event milestone_id assignee_id assignee_ids add_label_ids remove_label_ids subscription_event).each do |key|
+ permitted_attrs(type).each do |key|
params.delete(key) unless params[key].present?
end
@@ -26,5 +26,18 @@ module Issuable
success: !items.count.zero?
}
end
+
+ private
+
+ def permitted_attrs(type)
+ attrs = %i(state_event milestone_id assignee_id assignee_ids add_label_ids remove_label_ids subscription_event)
+
+ return
+ if type == 'issue'
+ attrs.merge(:assignee_ids)
+ else
+ attrs.merge(:assignee_id)
+ end
+ end
end
end
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 174e7c6e95b..0766df50ed2 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -79,7 +79,7 @@ module SystemNoteService
text_parts.join(' and ')
elsif old_assignees.any?
- "removed all assignees"
+ "removed assignee"
elsif issue.assignees.any?
"assigned to #{issue.assignees.map(&:to_reference).to_sentence}"
end
diff --git a/app/views/shared/issuable/_assignees.html.haml b/app/views/shared/issuable/_assignees.html.haml
index 36bbb1148d4..68f328c0856 100644
--- a/app/views/shared/issuable/_assignees.html.haml
+++ b/app/views/shared/issuable/_assignees.html.haml
@@ -1,9 +1,8 @@
- max_render = 3
- max = [max_render, issue.assignees.length].min
-- issue.assignees.each_with_index do |assignee, index|
- - if index < max
- = link_to_member(@project, assignee, name: false, title: "Assigned to :name")
+- issue.assignees.take(max) do |assignee|
+ = link_to_member(@project, assignee, name: false, title: "Assigned to :name")
- if issue.assignees.length > max_render
- counter = issue.assignees.length - max_render
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index 44e624c15a7..58c33924850 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -55,16 +55,17 @@
- options = { toggle_class: 'js-user-search js-author-search', title: 'Assign to', filter: true, dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author', placeholder: 'Search users', data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), author_id: issuable.author_id, field_name: "#{issuable.to_ability_name}[assignee_ids][]", issue_update: issuable_json_path(issuable), ability_name: issuable.to_ability_name, null_user: true } }
- - if issuable.instance_of?(Issue)
- - if issuable.assignees.length == 0
+ - if issuable.is_a?(Issue)
+ - unless issuable.assignees.any?
= hidden_field_tag "#{issuable.to_ability_name}[assignee_ids][]", 0, id: nil
- title = 'Select assignee'
- options[:toggle_class] += ' js-multiselect js-save-user-data'
- - options[:data][:field_name] = "#{issuable.to_ability_name}[assignee_ids][]"
- - options[:data][:multi_select] = true
- - options[:data]['dropdown-title'] = title
- - options[:data]['dropdown-header'] = 'Assignee'
- - options[:data]['max-select'] = 1
+ - data = { field_name: "#{issuable.to_ability_name}[assignee_ids][]" }
+ - data[:multi_select] = true
+ - data['dropdown-title'] = title
+ - data['dropdown-header'] = 'Assignee'
+ - data['max-select'] = 1
+ - options[:data].merge!(data)
- else
- title = 'Select assignee'
diff --git a/app/views/shared/issuable/form/_issue_assignee.html.haml b/app/views/shared/issuable/form/_issue_assignee.html.haml
index c33474ac3b4..66091d95a91 100644
--- a/app/views/shared/issuable/form/_issue_assignee.html.haml
+++ b/app/views/shared/issuable/form/_issue_assignee.html.haml
@@ -1,8 +1,9 @@
- issue = issuable
+- assignees = issue.assignees
.block.assignee
.sidebar-collapsed-icon.sidebar-collapsed-user{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: (issuable.assignee_list) }
- - if issue.assignees.any?
- - issue.assignees.each do |assignee|
+ - if assignees.any?
+ - assignees.each do |assignee|
= link_to_member(@project, assignee, size: 24)
- else
= icon('user', 'aria-hidden': 'true')
@@ -12,8 +13,8 @@
- if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right'
.value.hide-collapsed
- - if issue.assignees.any?
- - issue.assignees.each do |assignee|
+ - if assignees.any?
+ - assignees.each do |assignee|
= link_to_member(@project, assignee, size: 32, extra_class: 'bold') do
%span.username
= assignee.to_reference
diff --git a/doc/api/issues.md b/doc/api/issues.md
index 1d43b1298b9..1c0856ec6e3 100644
--- a/doc/api/issues.md
+++ b/doc/api/issues.md
@@ -100,7 +100,7 @@ Example response:
]
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## List group issues
@@ -192,7 +192,7 @@ Example response:
]
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## List project issues
@@ -284,7 +284,7 @@ Example response:
]
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## Single issue
@@ -359,7 +359,7 @@ Example response:
}
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## New issue
@@ -375,7 +375,7 @@ POST /projects/:id/issues
| `title` | string | yes | The title of an issue |
| `description` | string | no | The description of an issue |
| `confidential` | boolean | no | Set an issue to be confidential. Default is `false`. |
-| `assignee_ids` | Array[integer] | no | The ID of a user to assign issue |
+| `assignee_ids` | Array[integer] | no | The ID of the users to assign issue |
| `milestone_id` | integer | no | The ID of a milestone to assign issue |
| `labels` | string | no | Comma-separated label names for an issue |
| `created_at` | string | no | Date time string, ISO 8601 formatted, e.g. `2016-03-11T03:45:40Z` (requires admin or project owner rights) |
@@ -421,7 +421,7 @@ Example response:
}
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## Edit issue
@@ -439,7 +439,7 @@ PUT /projects/:id/issues/:issue_iid
| `title` | string | no | The title of an issue |
| `description` | string | no | The description of an issue |
| `confidential` | boolean | no | Updates an issue to be confidential |
-| `assignee_ids` | Array[integer] | no | The ID of a user to assign the issue to |
+| `assignee_ids` | Array[integer] | no | The ID of the users to assign the issue to |
| `milestone_id` | integer | no | The ID of a milestone to assign the issue to |
| `labels` | string | no | Comma-separated label names for an issue |
| `state_event` | string | no | The state event of an issue. Set `close` to close the issue and `reopen` to reopen it |
@@ -484,7 +484,7 @@ Example response:
}
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## Delete an issue
@@ -570,7 +570,7 @@ Example response:
}
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## Subscribe to an issue
@@ -635,7 +635,7 @@ Example response:
}
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## Unsubscribe from an issue
@@ -757,7 +757,7 @@ Example response:
}
```
-**Note**: `assignee` column is deprecated, it shows the first assignee only.
+**Note**: `assignee` column is deprecated, now we show it as a single-sized array `assignees` to conform to GitLab EE API.
## Set a time estimate for an issue
diff --git a/lib/api/helpers/common_helpers.rb b/lib/api/helpers/common_helpers.rb
index 6236fdd43ca..322624c6092 100644
--- a/lib/api/helpers/common_helpers.rb
+++ b/lib/api/helpers/common_helpers.rb
@@ -2,11 +2,11 @@ module API
module Helpers
module CommonHelpers
def convert_parameters_from_legacy_format(params)
- if params[:assignee_id].present?
- params[:assignee_ids] = [params.delete(:assignee_id)]
+ params.tap do |params|
+ if params[:assignee_id].present?
+ params[:assignee_ids] = [params.delete(:assignee_id)]
+ end
end
-
- params
end
end
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index da2b56c040b..79cac721202 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -1124,7 +1124,7 @@ describe API::Issues do
end
context 'CE restrictions' do
- it 'updates an issue with several assignee but only one has been applied' do
+ it 'updates an issue with several assignees but only one has been applied' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
assignee_ids: [user2.id, guest.id]
diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb
index 5b1639ca0d6..8fd56214752 100644
--- a/spec/services/issuable/bulk_update_service_spec.rb
+++ b/spec/services/issuable/bulk_update_service_spec.rb
@@ -62,7 +62,7 @@ describe Issuable::BulkUpdateService, services: true do
expect(result[:count]).to eq(1)
end
- it 'updates the assignee to the use ID passed' do
+ it 'updates the assignee to the user ID passed' do
assignee = create(:user)
project.team << [assignee, :developer]
@@ -100,7 +100,7 @@ describe Issuable::BulkUpdateService, services: true do
expect(result[:count]).to eq(1)
end
- it 'updates the assignee to the use ID passed' do
+ it 'updates the assignee to the user ID passed' do
assignee = create(:user)
project.team << [assignee, :developer]
expect { bulk_update(issue, assignee_ids: [assignee.id]) }