summaryrefslogtreecommitdiff
path: root/lib/banzai/filter/references/alert_reference_filter.rb
blob: 90fef536605495a761438f7f9a3d5305c1cbfc07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module Banzai
  module Filter
    module References
      class AlertReferenceFilter < IssuableReferenceFilter
        self.reference_type = :alert

        def self.object_class
          AlertManagement::Alert
        end

        def self.object_sym
          :alert
        end

        def parent_records(parent, ids)
          parent.alert_management_alerts.where(iid: ids.to_a)
        end

        def url_for_object(alert, project)
          ::Gitlab::Routing.url_helpers.details_project_alert_management_url(
            project,
            alert.iid,
            only_path: context[:only_path]
          )
        end
      end
    end
  end
end