Skip to content

Commit

Permalink
Minor cleanup of incident view to simplify
Browse files Browse the repository at this point in the history
Simplifies the incident view, compacting the output, adding some extra
data, and fixing some formatting.

Signed-off-by: Chris Collins <[email protected]>
  • Loading branch information
clcollins committed Jun 20, 2024
1 parent 31adca8 commit 02ad468
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions pkg/tui/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,23 @@ var funcMap = template.FuncMap{
"Truncate": func(s string) string {
return fmt.Sprintf("%s ...", s[:5])
},
"ToLink": func(s, link string) string {
return fmt.Sprintf("[%s](%s)", s, link)
},
"ToUpper": strings.ToUpper,
"Last": func(i, length int) bool {
return i == length-1
},
}

const incidentTemplate = `
{{- if .Priority -}}
# {{ .Priority }} {{ .ID }} - {{ .Status }}
{{- else -}}
# {{ .ID }} - {{ .Status }}
{{- end }}
{{ if .Priority }}PRIORITY {{ .Priority }} - {{ end }}{{ .Title }} - {{ .HTMLURL }}
{{ ToLink .Title .HTMLURL }}
* Service: {{ .Service }}
* Urgency: {{ .Urgency }}
Expand All @@ -269,20 +279,20 @@ const incidentTemplate = `
{{ if not .Acknowledged -}}
Assigned to:{{ range $assignee := .Assigned }}
+ *{{ $assignee }}* *(not yet acknowledged)*
{{ end -}}
{{ else -}}
Acknowledged by:{{ range $ack := .Acknowledged }}
+ **{{ $ack }}**
{{ end -}}
{{ end -}}
{{ end }}
{{- else -}}
{{ $length := len .Acknowledged }}
Acknowledged by: {{ range $i, $ack := .Acknowledged -}}
{{ if Last $i $length }}**{{ $ack }}**{{ else }}**{{ $ack }},**{{ end }}
{{ end }}
{{- end -}}
## Notes
{{ if .Notes }}
{{ range $note := .Notes }}
> {{ $note.Content }}
- {{ $note.User }} @ {{ $note.Created }}
-- {{ $note.User }} @ {{ $note.Created }}
{{ end }}
{{ else }}
_none_
Expand All @@ -291,17 +301,19 @@ _none_
## Alerts ({{ len .Alerts }})
{{ range $alert := .Alerts }}
_{{ $alert.ID }}_{{ if $alert.Name }}- _{{ $alert.Name }}_{{ end }}
{{ $alert.ID }} - {{ $alert.Status }}
{{ if $alert.Name }}
_{{- $alert.Name }}_
{{- end }}
{{ $alert.HTMLURL }}
* Cluster: {{ $alert.Cluster }}
* Service: {{ $alert.Service }}
* Created: {{ $alert.Created }}
* SOP: {{ $alert.Link }}
Details :
* Service: {{ $alert.Service }}
* Status: {{ $alert.Status }}
* Created: {{ $alert.Created }}
* Link: {{ $alert.HTMLURL }}
{{ range $key, $value := $alert.Details }}
* {{ $key }}: {{ $value }}
{{ end }}
Expand All @@ -312,6 +324,7 @@ Details :
func renderIncidentMarkdown(content string) (string, error) {
renderer, err := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithWordWrap(0),
)
if err != nil {
return "", err
Expand Down

0 comments on commit 02ad468

Please sign in to comment.