Fix expire buttons on the silences page (#1171)
* Only show confirmation for the specific silence * Update bindata.go
This commit is contained in:
parent
92c04096a8
commit
6f8ccb031c
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
Loading…
Reference in New Issue