Fix UI when no silences are present (#1090)

* Explicitly initialize silences list to avoid "null" JSON

* Wrap "No silences found" message in error box

* bindata fixup
This commit is contained in:
Julius Volz 2017-11-11 14:48:48 +01:00 committed by stuart nelson
parent 133c888ef3
commit fdee5fcbfc
3 changed files with 7 additions and 4 deletions

View File

@ -624,7 +624,7 @@ func (api *API) listSilences(w http.ResponseWriter, r *http.Request) {
sils = append(sils, s)
}
var active, pending, expired, silences []*types.Silence
var active, pending, expired []*types.Silence
for _, s := range sils {
switch s.Status.State {
@ -647,6 +647,9 @@ func (api *API) listSilences(w http.ResponseWriter, r *http.Request) {
return expired[i].EndsAt.After(expired[j].EndsAt)
})
// Initialize silences explicitly to an empty list (instead of nil)
// So that it does not get converted to "null" in JSON.
silences := []*types.Silence{}
silences = append(silences, active...)
silences = append(silences, pending...)
silences = append(silences, expired...)

View File

@ -52,7 +52,7 @@ tabView currentState ( state, silences ) =
silencesView : Bool -> List Silence -> Html Msg
silencesView showConfirmationDialog silences =
if List.isEmpty silences then
div [] [ text "No silences found" ]
Utils.Views.error "No silences found"
else
ul [ class "list-group" ]
(List.map (Views.SilenceList.SilenceView.view showConfirmationDialog) silences)

File diff suppressed because one or more lines are too long