frontend: Show current nixpkgs commit (#791)

This commit is contained in:
Janne Heß 2024-06-10 11:34:21 +02:00 committed by GitHub
parent cf2fd8e388
commit 120d91e751
Failed to generate hash of commit

View file

@ -31,6 +31,7 @@ module Search exposing
, viewSearchInput
)
import Array
import Base64
import Browser.Dom
import Browser.Navigation
@ -39,6 +40,7 @@ import Html
( Html
, a
, button
, code
, div
, form
, h1
@ -1039,33 +1041,49 @@ viewResults nixosChannels model result viewSuccess _ outMsg categoryName =
total =
String.fromInt result.hits.total.value
in
[ div []
[ Html.map outMsg <| viewSortSelection model
, h2 []
(List.append
[ text "Showing results "
, text from
, text "-"
, text to
, text " of "
]
(if result.hits.total.value == 10000 then
[ text "more than 10000."
, p [] [ text "Please provide more precise search terms." ]
]
(List.append
[ Html.map outMsg <| viewSortSelection model
, h2 []
(List.append
[ text "Showing results "
, text from
, text "-"
, text to
, text " of "
]
(if result.hits.total.value == 10000 then
[ text "more than 10000."
, p [] [ text "Please provide more precise search terms." ]
]
else
[ strong []
[ text total
, text " "
, text categoryName
]
else
[ strong []
[ text total
, text " "
, text categoryName
]
, text "."
]
)
)
]
(case List.head result.hits.hits of
Nothing -> []
Just elem ->
case Array.get 3 (Array.fromList (String.split "-" elem.index)) of
Nothing -> []
Just commit ->
[
text "Data from nixpkgs "
, a [ href ("https://github.com/NixOS/nixpkgs/commit/" ++ commit) ]
[ (code [] [ text (String.slice 0 8 commit) ]) ]
, text "."
]
)
)
]
]
)
)
, viewSuccess nixosChannels model.channel model.showInstallDetails model.show result.hits.hits
, Html.map outMsg <| viewPager model result.hits.total.value
]