diff options
author | Rémy Coutable <remy@rymai.me> | 2018-10-04 11:25:55 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-10-04 11:25:55 +0000 |
commit | cd3adcbbc06d5ac9afd93c25ad536b7f96ce7c85 (patch) | |
tree | 4b96779954637bd6f59ca6e3d9a90de5db324147 | |
parent | 9e44c1b3cfea06cc9e88767bee2117091f5cd012 (diff) | |
parent | 07c3778aee658a7e77c14f22745f78893da023f2 (diff) | |
download | gitlab-ce-cd3adcbbc06d5ac9afd93c25ad536b7f96ce7c85.tar.gz |
Merge branch 'ce-7723-epic-commands-autocomplete' into 'master'
Port: Add checks to InterpretService conditions
See merge request gitlab-org/gitlab-ce!22047
-rw-r--r-- | app/services/quick_actions/interpret_service.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb index 8933bef29ee..defa579f9a8 100644 --- a/app/services/quick_actions/interpret_service.rb +++ b/app/services/quick_actions/interpret_service.rb @@ -210,9 +210,14 @@ module QuickActions 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 - current_user.can?(:"admin_#{issuable.to_ability_name}", project) && + project && + current_user.can?(:"admin_#{issuable.to_ability_name}", project) && available_labels.any? end command :label do |labels_param| @@ -286,7 +291,8 @@ module QuickActions end params '#issue | !merge_request' condition do - current_user.can?(:"update_#{issuable.to_ability_name}", issuable) + [MergeRequest, Issue].include?(issuable.class) && + current_user.can?(:"update_#{issuable.to_ability_name}", issuable) end parse_params do |issuable_param| extract_references(issuable_param, :issue).first || @@ -443,7 +449,8 @@ module QuickActions end params '<time(1h30m | -1h30m)> <date(YYYY-MM-DD)>' condition do - current_user.can?(:"admin_#{issuable.to_ability_name}", issuable) + issuable.is_a?(TimeTrackable) && + current_user.can?(:"admin_#{issuable.to_ability_name}", issuable) end parse_params do |raw_time_date| Gitlab::QuickActions::SpendTimeAndDateSeparator.new(raw_time_date).execute @@ -493,7 +500,7 @@ module QuickActions 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 @@ module QuickActions 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) |