diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-28 18:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-28 18:09:29 +0300 |
commit | 37ae6b54ba524c438d1b756ce3ca29bbcec4e897 (patch) | |
tree | e0cd3b9a5f19daec493de537d3214ac390101462 /app/finders | |
parent | c74b7b5e4345702a1d59c72d923c3580ef157a59 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/alert_management/alerts_finder.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/finders/alert_management/alerts_finder.rb b/app/finders/alert_management/alerts_finder.rb new file mode 100644 index 00000000000..b2961329821 --- /dev/null +++ b/app/finders/alert_management/alerts_finder.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module AlertManagement + class AlertsFinder + def initialize(current_user, project, params) + @current_user = current_user + @project = project + @params = params + end + + def execute + return AlertManagement::Alert.none unless authorized? + + collection = project.alert_management_alerts + by_iid(collection) + end + + private + + attr_reader :current_user, :project, :params + + def by_iid(collection) + return collection unless params[:iid] + + collection.for_iid(params[:iid]) + end + + def authorized? + Ability.allowed?(current_user, :read_alert_management_alerts, project) + end + end +end |