summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-12-01 19:39:40 -0200
committerFelipe Artur <felipefac@gmail.com>2016-12-02 16:26:17 -0200
commit493faec6bf67895f15f44cdde9859743af8b99aa (patch)
treecfb3f54b7371959083c4ca604c2ca0d26274878a
parent089ca2df590d22489fde16e9dabdc4f25faface3 (diff)
downloadgitlab-ce-493faec6bf67895f15f44cdde9859743af8b99aa.tar.gz
Allow non team members to unassign themselves from issuablesissue_25085
-rw-r--r--app/assets/javascripts/users_select.js8
-rw-r--r--app/services/issuable_base_service.rb12
-rw-r--r--app/services/issues/base_service.rb4
-rw-r--r--app/services/merge_requests/base_service.rb4
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml2
-rw-r--r--changelogs/unreleased/issue_25085.yml4
6 files changed, 26 insertions, 8 deletions
diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js
index c6e18fad832..29779e3c20a 100644
--- a/app/assets/javascripts/users_select.js
+++ b/app/assets/javascripts/users_select.js
@@ -16,6 +16,7 @@
this.currentUser = JSON.parse(currentUser);
}
}
+
$('.js-user-search').each((function(_this) {
return function(i, dropdown) {
var options = {};
@@ -64,6 +65,13 @@
return assignTo(_this.currentUser.id);
}
});
+
+ $block.on('click', '.js-unassign-yourself', function(e) {
+ e.preventDefault();
+
+ return assignTo("");
+ });
+
assignTo = function(selected) {
var data;
data = {};
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index ce68e433ab8..ac429f9607b 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -36,7 +36,7 @@ class IssuableBaseService < BaseService
end
end
- def filter_params(issuable_ability_name = :issue)
+ def filter_params(issuable_ability_name: :issue, issuable: nil)
filter_assignee
filter_milestone
filter_labels
@@ -49,8 +49,12 @@ class IssuableBaseService < BaseService
params.delete(:add_label_ids)
params.delete(:remove_label_ids)
params.delete(:label_ids)
- params.delete(:assignee_id)
params.delete(:due_date)
+
+ # User should be able to unassign himself
+ if issuable.try(:author) != current_user && params[:assignee_id].present?
+ params.delete(:assignee_id)
+ end
end
end
@@ -137,7 +141,7 @@ class IssuableBaseService < BaseService
def create(issuable)
merge_slash_commands_into_params!(issuable)
- filter_params
+ filter_params(issuable_ability_name: :issue)
params.delete(:state_event)
params[:author] ||= current_user
@@ -179,7 +183,7 @@ class IssuableBaseService < BaseService
change_state(issuable)
change_subscription(issuable)
change_todo(issuable)
- filter_params
+ filter_params(issuable: issuable)
old_labels = issuable.labels.to_a
old_mentioned_users = issuable.mentioned_users.to_a
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index 9ea3ce084ba..fdc879b7a80 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -9,8 +9,8 @@ module Issues
private
- def filter_params
- super(:issue)
+ def filter_params(issuable_ability_name: :issue, issuable: nil)
+ super(issuable_ability_name: :issue)
end
def execute_hooks(issue, action = 'open')
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb
index 800fd39c424..791966188c2 100644
--- a/app/services/merge_requests/base_service.rb
+++ b/app/services/merge_requests/base_service.rb
@@ -38,8 +38,8 @@ module MergeRequests
private
- def filter_params
- super(:merge_request)
+ def filter_params(issuable_ability_name: :issue, issuable: nil)
+ super(issuable_ability_name: :merge_request)
end
def merge_requests_for(branch)
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index 02427650219..59e84284324 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -29,6 +29,8 @@
= icon('spinner spin', class: 'block-loading')
- if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right'
+ - elsif issuable.assignee_id == current_user.try(:id)
+ = link_to 'Unassign', '#', class: 'js-unassign-yourself pull-right'
.value.hide-collapsed
- if issuable.assignee
= link_to_member(@project, issuable.assignee, size: 32, extra_class: 'bold') do
diff --git a/changelogs/unreleased/issue_25085.yml b/changelogs/unreleased/issue_25085.yml
new file mode 100644
index 00000000000..50aeb9b8290
--- /dev/null
+++ b/changelogs/unreleased/issue_25085.yml
@@ -0,0 +1,4 @@
+---
+title: Allow non team members to unassign themselves from issuables
+merge_request:
+author: