Commit ec9c220a authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch 'ce-7723-epic-commands-autocomplete' into 'master'

Port: Add checks to InterpretService conditions

See merge request gitlab-org/gitlab-ce!22047
......@@ -210,8 +210,13 @@ def extractor
end
params '~label1 ~"label 2"'
condition do
available_labels = LabelsFinder.new(current_user, project_id: project.id, include_ancestor_groups: true).execute
if project
available_labels = LabelsFinder
.new(current_user, project_id: project.id, include_ancestor_groups: true)
.execute
end
project &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) &&
available_labels.any?
end
......@@ -286,6 +291,7 @@ def extractor
end
params '#issue | !merge_request'
condition do
[MergeRequest, Issue].include?(issuable.class) &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
end
parse_params do |issuable_param|
......@@ -443,6 +449,7 @@ def extractor
end
params '<time(1h30m | -1h30m)> <date(YYYY-MM-DD)>'
condition do
issuable.is_a?(TimeTrackable) &&
current_user.can?(:"admin_#{issuable.to_ability_name}", issuable)
end
parse_params do |raw_time_date|
......@@ -493,7 +500,7 @@ def extractor
desc "Lock the discussion"
explanation "Locks the discussion"
condition do
issuable.is_a?(Issuable) &&
[MergeRequest, Issue].include?(issuable.class) &&
issuable.persisted? &&
!issuable.discussion_locked? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", issuable)
......@@ -505,7 +512,7 @@ def extractor
desc "Unlock the discussion"
explanation "Unlocks the discussion"
condition do
issuable.is_a?(Issuable) &&
[MergeRequest, Issue].include?(issuable.class) &&
issuable.persisted? &&
issuable.discussion_locked? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", issuable)
......
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