diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /app/presenters/alert_management/alert_presenter.rb | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'app/presenters/alert_management/alert_presenter.rb')
-rw-r--r-- | app/presenters/alert_management/alert_presenter.rb | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb index 5debe6d5dbd..4bfa3dc9a13 100644 --- a/app/presenters/alert_management/alert_presenter.rb +++ b/app/presenters/alert_management/alert_presenter.rb @@ -8,10 +8,11 @@ module AlertManagement MARKDOWN_LINE_BREAK = " \n" HORIZONTAL_LINE = "\n\n---\n\n" + INCIDENT_LABEL_NAME = ::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES[:title] delegate :metrics_dashboard_url, :runbook, to: :parsed_payload - def initialize(alert, _attributes = {}) + def initialize(alert, **attributes) super @alert = alert @@ -38,6 +39,30 @@ module AlertManagement Gitlab::Utils::InlineHash.merge_keys(payload) end + def show_incident_issues_link? + project.incident_management_setting&.create_issue? + end + + def show_performance_dashboard_link? + prometheus_alert.present? + end + + def incident_issues_link + project_issues_url(project, label_name: INCIDENT_LABEL_NAME) + end + + def performance_dashboard_link + if environment + metrics_project_environment_url(project, environment) + else + metrics_project_environments_url(project) + end + end + + def email_title + [environment&.name, query_title].compact.join(': ') + end + private attr_reader :alert, :project @@ -80,5 +105,11 @@ module AlertManagement def host_links hosts.join(' ') end + + def query_title + return title unless prometheus_alert + + "#{prometheus_alert.title} #{prometheus_alert.computed_operator} #{prometheus_alert.threshold} for 5 minutes" + end end end |