Display attributes of flakes in a more expected way (#397)

This commit is contained in:
Yannik Sander 2021-12-26 16:19:15 +01:00 committed by GitHub
parent 3dfcf4fd45
commit 87851618b6
Failed to generate hash of commit
2 changed files with 29 additions and 25 deletions

View file

@ -174,6 +174,7 @@ viewResultItem channel _ show item =
case Html.Parser.run <| String.trim value of
Ok [ Html.Parser.Element "rendered-docbook" _ nodes ] ->
Just <| Html.Parser.Util.toVirtualDom nodes
Ok _ ->
Nothing
@ -275,10 +276,12 @@ viewResultItem channel _ show item =
flakeOrNixpkgs =
case ( item.source.flakeName, item.source.flake, item.source.flakeUrl ) of
-- its a flake
( Just name, Just ( _, module_ ), Just flakeUrl_ ) ->
( Just name, Just ( flake, attr ), Just flakeUrl_ ) ->
Just
[ li []
[ a [ href flakeUrl_ ] [ text name ]
[ a [ href flakeUrl_ ] [ text flake ]
, text "#"
, text attr
]
]

View file

@ -390,7 +390,7 @@ viewResultItem channel showInstallDetails show item =
"mailto:" ++ email
Nothing ->
"#"
"#"
]
[ text "(mail)" ]
]
@ -398,7 +398,8 @@ viewResultItem channel showInstallDetails show item =
mailtoAllMaintainers maintainers =
let
maintainerMails = List.filterMap (\m -> m.email) maintainers
maintainerMails =
List.filterMap (\m -> m.email) maintainers
in
li []
[ a
@ -584,16 +585,27 @@ viewResultItem channel showInstallDetails show item =
isOpen =
Just item.source.attr_name == show
flakeItem =
Maybe.map Tuple.second item.source.flakeUrl
|> Maybe.map2
(\name resolved ->
[ li [ trapClick ]
[ createShortDetailsItem name resolved ]
flakeOrNixpkgs =
case ( item.source.flakeName, item.source.flakeUrl ) of
-- its a flake
( Just name, Just ( flakeIdent, flakeUrl ) ) ->
[ a [ href flakeUrl ] [ text flakeIdent ]
, text "#"
, a
[ onClick toggle
, href ""
]
[ text item.source.attr_name ]
]
_ ->
[ a
[ onClick toggle
, href ""
]
)
item.source.flakeName
|> Maybe.withDefault []
[ text item.source.attr_name ]
]
in
li
[ class "package"
@ -603,18 +615,7 @@ viewResultItem channel showInstallDetails show item =
([]
|> List.append longerPackageDetails
|> List.append
[ ul [ class "search-result-button" ]
(List.append
flakeItem
[ li []
[ a
[ onClick toggle
, href ""
]
[ text item.source.attr_name ]
]
]
)
[ span [] flakeOrNixpkgs
, div [] [ text <| Maybe.withDefault "" item.source.description ]
, shortPackageDetails
, Search.showMoreButton toggle isOpen