Class: AlertManagement::AlertPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Includes:
ActionView::Helpers::UrlHelper, Gitlab::Utils::StrongMemoize, IncidentManagement::Settings
Defined in:
app/presenters/alert_management/alert_presenter.rb

Direct Known Subclasses

PrometheusAlertPresenter

Constant Summary collapse

MARKDOWN_LINE_BREAK =
"  \n".freeze

Instance Attribute Summary

Attributes included from Gitlab::View::Presenter::Base

#subject

Instance Method Summary collapse

Methods included from IncidentManagement::Settings

#auto_close_incident?, #incident_management_setting, #process_issues?

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from Gitlab::View::Presenter::Base

#can?, #declarative_policy_delegate, #is_a?, #present, #url_builder, #web_path, #web_url

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

#initialize(alert, _attributes = {}) ⇒ AlertPresenter

Returns a new instance of AlertPresenter.


11
12
13
14
15
16
# File 'app/presenters/alert_management/alert_presenter.rb', line 11

def initialize(alert, _attributes = {})
  super

  @alert = alert
  @project = alert.project
end

Instance Method Details

#detailsObject


45
46
47
# File 'app/presenters/alert_management/alert_presenter.rb', line 45

def details
  Gitlab::Utils::InlineHash.merge_keys(payload)
end

#details_urlObject


41
42
43
# File 'app/presenters/alert_management/alert_presenter.rb', line 41

def details_url
  details_project_alert_management_url(project, alert.iid)
end

#issue_descriptionObject


18
19
20
21
22
23
24
25
26
# File 'app/presenters/alert_management/alert_presenter.rb', line 18

def issue_description
  horizontal_line = "\n\n---\n\n"

  [
    issue_summary_markdown,
    alert_markdown,
    incident_management_setting.issue_template_content
  ].compact.join(horizontal_line)
end

#issue_summary_markdownObject


32
33
34
35
36
37
# File 'app/presenters/alert_management/alert_presenter.rb', line 32

def issue_summary_markdown
  <<~MARKDOWN.chomp
    #{}
    #{alert_details}#{metric_embed_for_alert}
  MARKDOWN
end

#metrics_dashboard_urlObject


39
# File 'app/presenters/alert_management/alert_presenter.rb', line 39

def metrics_dashboard_url; end

#start_timeObject


28
29
30
# File 'app/presenters/alert_management/alert_presenter.rb', line 28

def start_time
  started_at&.strftime('%d %B %Y, %-l:%M%p (%Z)')
end