From d3834271e02b9a13a46a2eda27a0d2e36a54ced3 Mon Sep 17 00:00:00 2001 From: Matt Murphy Date: Sun, 7 Jun 2020 17:56:13 -0400 Subject: [PATCH] Always show incidents if configured --- modules/pagerduty/widget.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/pagerduty/widget.go b/modules/pagerduty/widget.go index 1275e0bb..2ba4048f 100644 --- a/modules/pagerduty/widget.go +++ b/modules/pagerduty/widget.go @@ -69,13 +69,17 @@ func (widget *Widget) Refresh() { func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerduty.Incident) string { var str string - if len(incidents) > 0 { - str += "[yellow]Incidents[white]\n" - for _, incident := range incidents { - str += fmt.Sprintf("[%s]%s[white]\n", widget.settings.common.Colors.Subheading, incident.Summary) - str += fmt.Sprintf("Status: %s\n", incident.Status) - str += fmt.Sprintf("Service: %s\n", incident.Service.Summary) - str += fmt.Sprintf("Escalation: %s\n", incident.EscalationPolicy.Summary) + if widget.settings.showIncidents { + str += "[yellow] Incidents[white]" + if len(incidents) > 0 { + for _, incident := range incidents { + str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Subheading, incident.Summary) + str += fmt.Sprintf(" Status: %s\n", incident.Status) + str += fmt.Sprintf(" Service: %s\n", incident.Service.Summary) + str += fmt.Sprintf(" Escalation: %s\n", incident.EscalationPolicy.Summary) + } + } else { + str += "\n No unresolved incidents\n" } } @@ -102,7 +106,7 @@ func (widget *Widget) contentFrom(onCalls []pagerduty.OnCall, incidents []pagerd sort.Strings(keys) if len(keys) > 0 { - str += fmt.Sprintf("[%s] Schedules[white]\n", widget.settings.common.Colors.Subheading) + str += fmt.Sprintf("\n[%s] Schedules[white]\n", widget.settings.common.Colors.Subheading) // Print out policies, and escalation order of users for _, key := range keys {