mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-09-30 08:38:22 +00:00
Externalize error messages
This commit is contained in:
@@ -19,7 +19,8 @@ type alias Model =
|
||||
|
||||
type State
|
||||
= Empty
|
||||
| Failed String
|
||||
| Failed Http.Error
|
||||
| GenericFail String
|
||||
| Success InviteResult
|
||||
|
||||
|
||||
@@ -29,6 +30,9 @@ isFailed state =
|
||||
Failed _ ->
|
||||
True
|
||||
|
||||
GenericFail _ ->
|
||||
True
|
||||
|
||||
_ ->
|
||||
False
|
||||
|
||||
|
@@ -4,7 +4,6 @@ import Api
|
||||
import Api.Model.GenInvite exposing (GenInvite)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.NewInvite.Data exposing (..)
|
||||
import Util.Http
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
@@ -24,7 +23,7 @@ update flags msg model =
|
||||
( { model | result = Success res }, Cmd.none )
|
||||
|
||||
else
|
||||
( { model | result = Failed res.message }, Cmd.none )
|
||||
( { model | result = GenericFail res.message }, Cmd.none )
|
||||
|
||||
InviteResp (Err err) ->
|
||||
( { model | result = Failed (Util.Http.errorToString err) }, Cmd.none )
|
||||
( { model | result = Failed err }, Cmd.none )
|
||||
|
@@ -43,7 +43,11 @@ viewContent texts flags _ model =
|
||||
[ text texts.invitationKey
|
||||
]
|
||||
, div [ class "relative" ]
|
||||
[ div [ class "inline-flex items-center justify-center absolute left-0 top-0 h-full w-10 text-gray-400 dark:text-bluegray-400 " ]
|
||||
[ div
|
||||
[ class "inline-flex items-center justify-center"
|
||||
, class "absolute left-0 top-0 h-full w-10"
|
||||
, class "text-gray-400 dark:text-bluegray-400"
|
||||
]
|
||||
[ i [ class "fa fa-key" ] []
|
||||
]
|
||||
, input
|
||||
@@ -93,13 +97,16 @@ resultMessage texts model =
|
||||
]
|
||||
]
|
||||
[ case model.result of
|
||||
Failed m ->
|
||||
p [] [ text m ]
|
||||
Failed err ->
|
||||
text (texts.httpError err)
|
||||
|
||||
GenericFail m ->
|
||||
text m
|
||||
|
||||
Success r ->
|
||||
div [ class "" ]
|
||||
[ p []
|
||||
[ text r.message
|
||||
[ text texts.newInvitationCreated
|
||||
, text (" " ++ texts.invitationKey ++ ":")
|
||||
]
|
||||
, pre [ class "text-center font-mono mt-4" ]
|
||||
|
Reference in New Issue
Block a user