Fix expire buttons on the silences page (#1171)

* Only show confirmation for the specific silence

* Update bindata.go
This commit is contained in:
Andrey Kuzmin 2018-01-02 12:25:34 +01:00 committed by GitHub
parent 92c04096a8
commit 6f8ccb031c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 11 deletions

View File

@ -1,6 +1,6 @@
module Views.SilenceList.Types exposing (Model, SilenceListMsg(..), initSilenceList)
import Silences.Types exposing (Silence, State(Active))
import Silences.Types exposing (Silence, State(Active), SilenceId)
import Utils.Types exposing (ApiData(Initial))
import Views.FilterBar.Types as FilterBar
@ -18,7 +18,7 @@ type alias Model =
{ silences : ApiData (List Silence)
, filterBar : FilterBar.Model
, tab : State
, showConfirmationDialog : Bool
, showConfirmationDialog : Maybe SilenceId
}
@ -27,5 +27,5 @@ initSilenceList =
{ silences = Initial
, filterBar = FilterBar.initFilterBar
, tab = Active
, showConfirmationDialog = False
, showConfirmationDialog = Nothing
}

View File

@ -18,20 +18,20 @@ update msg model filter basePath apiUrl =
( { model
| filterBar = FilterBar.setMatchers filter model.filterBar
, silences = Loading
, showConfirmationDialog = False
, showConfirmationDialog = Nothing
}
, Api.getSilences apiUrl filter SilencesFetch
)
ConfirmDestroySilence silence refresh ->
( { model | showConfirmationDialog = True }
( { model | showConfirmationDialog = Just silence.id }
, Cmd.none
)
DestroySilence silence refresh ->
-- TODO: "Deleted id: ID" growl
-- TODO: Check why POST isn't there but is accepted
{ model | silences = Loading, showConfirmationDialog = False }
{ model | silences = Loading, showConfirmationDialog = Nothing }
! [ Api.destroy apiUrl silence (always FetchSilences)
, if refresh then
Navigation.newUrl (basePath ++ "#/silences")

View File

@ -2,7 +2,7 @@ module Views.SilenceList.Views exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Silences.Types exposing (Silence, State(..), stateToString)
import Silences.Types exposing (Silence, State(..), stateToString, SilenceId)
import Types exposing (Msg(MsgForSilenceList, Noop, UpdateFilter))
import Utils.Api exposing (withDefault)
import Utils.String as StringUtils
@ -49,13 +49,20 @@ tabView currentState ( state, silences ) =
]
silencesView : Bool -> List Silence -> Html Msg
silencesView : Maybe SilenceId -> List Silence -> Html Msg
silencesView showConfirmationDialog silences =
if List.isEmpty silences then
Utils.Views.error "No silences found"
else
ul [ class "list-group" ]
(List.map (Views.SilenceList.SilenceView.view showConfirmationDialog) silences)
(List.map
(\silence ->
Views.SilenceList.SilenceView.view
(showConfirmationDialog == Just silence.id)
silence
)
silences
)
groupSilencesByState : List Silence -> List ( State, List Silence )

File diff suppressed because one or more lines are too long