Commit 935b2655 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Change alert list type

Change the type of alert details list from bulleted to description list
parent 98344b6b
......@@ -4,6 +4,7 @@ module Projects
module Prometheus
class AlertPresenter < Gitlab::View::Presenter::Delegated
RESERVED_ANNOTATIONS = %w(gitlab_incident_markdown).freeze
MARKDOWN_LINE_BREAK = " \n".freeze
def full_title
[environment_name, alert_title].compact.join(': ')
......@@ -57,10 +58,10 @@ module Projects
def metadata_list
metadata = []
metadata << bullet('starts_at', starts_at) if starts_at
metadata << bullet('full_query', backtick(full_query)) if full_query
metadata << list_item('starts_at', starts_at) if starts_at
metadata << list_item('full_query', backtick(full_query)) if full_query
metadata.join("\n")
metadata.join(MARKDOWN_LINE_BREAK)
end
def alert_details
......@@ -78,13 +79,13 @@ module Projects
strong_memoize(:annotation_list) do
annotations
.reject { |annotation| RESERVED_ANNOTATIONS.include?(annotation.label) }
.map { |annotation| bullet(annotation.label, annotation.value) }
.join("\n")
.map { |annotation| list_item(annotation.label, annotation.value) }
.join(MARKDOWN_LINE_BREAK)
end
end
def bullet(key, value)
"* #{key}: #{value}"
def list_item(key, value)
"**#{key}:** #{value}".strip
end
def backtick(value)
......
......@@ -45,7 +45,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
* starts_at: #{presenter.starts_at}
**starts_at:** #{presenter.starts_at}
MARKDOWN
)
......@@ -62,12 +62,11 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
* starts_at: #{presenter.starts_at}
**starts_at:** #{presenter.starts_at}
#### Alert Details
* foo: value1
* bar: value2
**foo:** value1 \n**bar:** value2
MARKDOWN
)
end
......@@ -83,8 +82,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~MARKDOWN.chomp
#### Summary
* starts_at: #{presenter.starts_at}
* full_query: `query`
**starts_at:** #{presenter.starts_at} \n**full_query:** `query`
MARKDOWN
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment