Class: AlertManagement::AlertPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Includes:
IncidentManagement::Settings
Defined in:
app/presenters/alert_management/alert_presenter.rb

Constant Summary collapse

MARKDOWN_LINE_BREAK =
"  \n"
HORIZONTAL_LINE =
"\n\n---\n\n"

Instance Method Summary collapse

Methods included from IncidentManagement::Settings

#auto_close_incident?, #incident_management_setting, #process_issues?

Methods included from Gitlab::Utils::DelegatorOverride

#delegator_override, #delegator_override_with, #delegator_target, validator, validators, verify!

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

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

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

#initialize(alert, **attributes) ⇒ AlertPresenter

Returns a new instance of AlertPresenter.



15
16
17
18
19
20
# File 'app/presenters/alert_management/alert_presenter.rb', line 15

def initialize(alert, **attributes)
  super

  @alert = alert
  @project = alert.project
end

Instance Method Details

#detailsObject



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

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

#details_urlObject



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

def details_url
  details_project_alert_management_url(project, alert.iid)
end

#email_titleObject



51
52
53
# File 'app/presenters/alert_management/alert_presenter.rb', line 51

def email_title
  [environment&.name, query_title].compact.join(': ')
end


47
48
49
# File 'app/presenters/alert_management/alert_presenter.rb', line 47

def incident_issues_link
  project_incidents_url(project)
end

#issue_descriptionObject



22
23
24
25
26
27
28
# File 'app/presenters/alert_management/alert_presenter.rb', line 22

def issue_description
  [
    issue_summary_markdown,
    alert_markdown,
    incident_management_setting.issue_template_content
  ].compact.join(HORIZONTAL_LINE)
end

#show_incident_issues_link?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/presenters/alert_management/alert_presenter.rb', line 43

def show_incident_issues_link?
  project.incident_management_setting&.create_issue?
end

#start_timeObject



30
31
32
# File 'app/presenters/alert_management/alert_presenter.rb', line 30

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