Skip to content

Show multiple warnings in documentation layout #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frontend/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ view model =
Skeleton.view never
{ title = "Not Found"
, header = []
, warning = Skeleton.NoProblems
, warnings = [Skeleton.NoProblems]
, attrs = Problem.styles
, kids = Problem.notFound
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/Page/Diff.elm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ view model =
[ Skeleton.authorSegment model.author
, Skeleton.projectSegment model.author model.project
]
, warning = Skeleton.NoProblems
, warnings = [Skeleton.NoProblems]
, attrs = [ class "pkg-overview" ]
, kids =
case model.releases of
Expand Down
14 changes: 7 additions & 7 deletions src/frontend/Page/Docs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ view : Model -> Skeleton.Details Msg
view model =
{ title = toTitle model
, header = toHeader model
, warning = toWarning model
, warnings = toWarnings model
, attrs = []
, kids =
[ viewContent model
Expand Down Expand Up @@ -296,18 +296,18 @@ toHeader model =
-- WARNING


toWarning : Model -> Skeleton.Warning
toWarning model =
toWarnings : Model -> List Skeleton.Warning
toWarnings model =
case Dict.get (model.author ++ "/" ++ model.project) renames of
Just (author, project) ->
Skeleton.WarnMoved author project
[Skeleton.WarnMoved author project]

Nothing ->
case model.outline of
Failure -> warnIfNewer model
Loading -> warnIfNewer model
Failure -> [warnIfNewer model]
Loading -> [warnIfNewer model]
Success outline ->
if isOld outline.elm then Skeleton.WarnOld else warnIfNewer model
if isOld outline.elm then [Skeleton.WarnOld, warnIfNewer model] else [warnIfNewer model]


warnIfNewer : Model -> Skeleton.Warning
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/Page/Help.elm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ view : Model -> Skeleton.Details msg
view model =
{ title = model.title
, header = []
, warning = Skeleton.NoProblems
, warnings = [Skeleton.NoProblems]
, attrs = []
, kids = [ viewContent model.title model.content ]
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/Page/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ view : Model -> Skeleton.Details Msg
view model =
{ title = "Elm Packages"
, header = []
, warning = Skeleton.NoProblems
, warnings = [Skeleton.NoProblems]
, attrs = []
, kids =
[ lazy2 viewSearch model.query model.entries
Expand Down
45 changes: 24 additions & 21 deletions src/frontend/Skeleton.elm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Utils.Logo as Logo
type alias Details msg =
{ title : String
, header : List Segment
, warning : Warning
, warnings : List Warning
, attrs : List (Attribute msg)
, kids : List (Html msg)
}
Expand Down Expand Up @@ -83,7 +83,7 @@ view toMsg details =
details.title
, body =
[ viewHeader details.header
, lazy viewWarning details.warning
, lazy viewWarnings details.warnings
, Html.map toMsg <|
div (class "center" :: style "flex" "1" :: details.attrs) details.kids
, viewFooter
Expand Down Expand Up @@ -126,35 +126,38 @@ viewSegment segment =

-- VIEW WARNING

viewWarnings : List Warning -> Html msg
viewWarnings warnings =
div [ class "header-underbar" ] <|
List.map viewWarning warnings

viewWarning : Warning -> Html msg
viewWarning warning =
div [ class "header-underbar" ] <|
case warning of
NoProblems ->
[]
case warning of
NoProblems ->
Html.text ""

WarnOld ->
[ p [ class "version-warning" ]
[ text "NOTE — this package is not compatible with Elm 0.19.1"
]
WarnOld ->
p [ class "version-warning" ]
[ text "NOTE — this package is not compatible with Elm 0.19.1"
]


WarnMoved author project ->
[ p [ class "version-warning" ]
[ text "NOTE — this package moved to "
, a [ href (Href.toVersion author project Nothing) ]
[ text (author ++ "/" ++ project)
]
WarnMoved author project ->
p [ class "version-warning" ]
[ text "NOTE — this package moved to "
, a [ href (Href.toVersion author project Nothing) ]
[ text (author ++ "/" ++ project)
]
]


WarnNewerVersion url version ->
[ p [ class "version-warning" ]
[ text "NOTE — the latest version is "
, a [ href url ] [ text (V.toString version) ]
]
WarnNewerVersion url version ->
p [ class "version-warning" ]
[ text "NOTE — the latest version is "
, a [ href url ] [ text (V.toString version) ]
]




Expand Down