mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 10:07:02 +00:00
ui: Render MIME parsing errors
This commit is contained in:
@@ -18,6 +18,7 @@ type alias Message =
|
|||||||
, text : String
|
, text : String
|
||||||
, html : String
|
, html : String
|
||||||
, attachments : List Attachment
|
, attachments : List Attachment
|
||||||
|
, errors : List Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -28,6 +29,13 @@ type alias Attachment =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type alias Error =
|
||||||
|
{ name : String
|
||||||
|
, detail : String
|
||||||
|
, severe : Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Message
|
decoder : Decoder Message
|
||||||
decoder =
|
decoder =
|
||||||
succeed Message
|
succeed Message
|
||||||
@@ -42,6 +50,7 @@ decoder =
|
|||||||
|> required "text" string
|
|> required "text" string
|
||||||
|> required "html" string
|
|> required "html" string
|
||||||
|> required "attachments" (list attachmentDecoder)
|
|> required "attachments" (list attachmentDecoder)
|
||||||
|
|> required "errors" (list errorDecoder)
|
||||||
|
|
||||||
|
|
||||||
attachmentDecoder : Decoder Attachment
|
attachmentDecoder : Decoder Attachment
|
||||||
@@ -50,3 +59,11 @@ attachmentDecoder =
|
|||||||
|> required "id" string
|
|> required "id" string
|
||||||
|> required "filename" string
|
|> required "filename" string
|
||||||
|> required "content-type" string
|
|> required "content-type" string
|
||||||
|
|
||||||
|
|
||||||
|
errorDecoder : Decoder Error
|
||||||
|
errorDecoder =
|
||||||
|
succeed Error
|
||||||
|
|> required "name" string
|
||||||
|
|> required "detail" string
|
||||||
|
|> required "severe" bool
|
||||||
|
|||||||
@@ -590,11 +590,34 @@ viewMessage zone message bodyMode =
|
|||||||
, dt [] [ text "Subject:" ]
|
, dt [] [ text "Subject:" ]
|
||||||
, dd [] [ text message.subject ]
|
, dd [] [ text message.subject ]
|
||||||
]
|
]
|
||||||
|
, messageErrors message
|
||||||
, messageBody message bodyMode
|
, messageBody message bodyMode
|
||||||
, attachments message
|
, attachments message
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
messageErrors : Message -> Html Msg
|
||||||
|
messageErrors message =
|
||||||
|
let
|
||||||
|
row error =
|
||||||
|
li []
|
||||||
|
[ span
|
||||||
|
[ classList [ ( "warn-severe", error.severe ) ] ]
|
||||||
|
[ text (error.name ++ ": ") ]
|
||||||
|
, text error.detail
|
||||||
|
]
|
||||||
|
in
|
||||||
|
case message.errors of
|
||||||
|
[] ->
|
||||||
|
text ""
|
||||||
|
|
||||||
|
errors ->
|
||||||
|
div [ class "warn" ]
|
||||||
|
[ div [] [ h3 [] [ text "MIME problems detected" ] ]
|
||||||
|
, ul [] (List.map row errors)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
messageBody : Message -> Body -> Html Msg
|
messageBody : Message -> Body -> Html Msg
|
||||||
messageBody message bodyMode =
|
messageBody message bodyMode =
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -141,6 +141,11 @@ h2 {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
background-color: #f58080;
|
background-color: #f58080;
|
||||||
background-image: linear-gradient(to bottom, #e86060 0, #f58080 100%);
|
background-image: linear-gradient(to bottom, #e86060 0, #f58080 100%);
|
||||||
@@ -203,6 +208,27 @@ h2 {
|
|||||||
padding: 10px !important;
|
padding: 10px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.warn {
|
||||||
|
--light: #f5f580;
|
||||||
|
--dark: #e8e860;
|
||||||
|
background-color: var(--light);
|
||||||
|
background-image: linear-gradient(to bottom, var(--dark) 0, var(--light) 100%);
|
||||||
|
border: 1px solid var(--dark);
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: 0 1px 2px rgba(0,0,0,.05);
|
||||||
|
padding: 6px 10px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warn li {
|
||||||
|
margin-left: 20px;
|
||||||
|
padding-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warn-severe {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
/** NAV BAR */
|
/** NAV BAR */
|
||||||
|
|
||||||
.navbar,
|
.navbar,
|
||||||
|
|||||||
Reference in New Issue
Block a user