summaryrefslogtreecommitdiff
path: root/app/services/labels
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2018-07-04 17:52:58 +0800
committerMark Chao <mchao@gitlab.com>2018-07-04 20:48:50 +0800
commit4f795ed823776912e8e9d6d4eb33c345ad2b56b9 (patch)
treec4886e114c6de12600c5ad25e5ab9a6cb9257342 /app/services/labels
parentecf9c145f6e4d170cd059df88743393d9e63c489 (diff)
downloadgitlab-ce-4f795ed823776912e8e9d6d4eb33c345ad2b56b9.tar.gz
Backport from EE !5954
Allow Labels::FindOrCreateService to find ancestor group labels Add authentication check on API endpoint Update flayignore
Diffstat (limited to 'app/services/labels')
-rw-r--r--app/services/labels/find_or_create_service.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/labels/find_or_create_service.rb b/app/services/labels/find_or_create_service.rb
index 079f611b3f3..a72da3c637f 100644
--- a/app/services/labels/find_or_create_service.rb
+++ b/app/services/labels/find_or_create_service.rb
@@ -20,6 +20,7 @@ module Labels
@available_labels ||= LabelsFinder.new(
current_user,
"#{parent_type}_id".to_sym => parent.id,
+ include_ancestor_groups: include_ancestor_groups?,
only_group_labels: parent_is_group?
).execute(skip_authorization: skip_authorization)
end
@@ -30,7 +31,8 @@ module Labels
new_label = available_labels.find_by(title: title)
if new_label.nil? && (skip_authorization || Ability.allowed?(current_user, :admin_label, parent))
- new_label = Labels::CreateService.new(params).execute(parent_type.to_sym => parent)
+ create_params = params.except(:include_ancestor_groups)
+ new_label = Labels::CreateService.new(create_params).execute(parent_type.to_sym => parent)
end
new_label
@@ -47,5 +49,9 @@ module Labels
def parent_is_group?
parent_type == "group"
end
+
+ def include_ancestor_groups?
+ params[:include_ancestor_groups] == true
+ end
end
end