Display deprecated channels (#489)

This commit is contained in:
Naïm Camille Favier 2022-06-08 01:55:26 +02:00 committed by GitHub
parent 75e8457105
commit 74ed61a915
Failed to generate hash of commit
2 changed files with 27 additions and 13 deletions

View file

@ -27,7 +27,7 @@
filteredChannels = filteredChannels =
lib.filterAttrs lib.filterAttrs
(n: v: (n: v:
builtins.elem v.status ["beta" "stable" "rolling"] && builtins.elem v.status ["rolling" "beta" "stable" "deprecated"] &&
lib.hasPrefix "nixos-" n && lib.hasPrefix "nixos-" n &&
v ? variant && v.variant == "primary" v ? variant && v.variant == "primary"
) )

View file

@ -170,15 +170,27 @@ type alias NixOSChannel =
type NixOSChannelStatus type NixOSChannelStatus
= Rolling = Rolling
| Stable
| Beta | Beta
| Stable
| Deprecated
channelTitle : NixOSChannel -> String channelBadge : NixOSChannelStatus -> List (Html msg)
channelTitle channel = channelBadge status =
if channel.status == Beta case status of
then channel.id ++ " (Beta)" Rolling ->
else channel.id -- [ span [ class "label label-success" ] [ text "Rolling" ] ]
[]
Beta ->
[ span [ class "label label-info" ] [ text "Beta" ] ]
Stable ->
-- [ span [ class "label label-success" ] [ text "Stable" ] ]
[]
Deprecated ->
[ span [ class "label label-warning" ] [ text "Deprecated" ] ]
decodeNixOSChannels : Json.Decode.Decoder NixOSChannels decodeNixOSChannels : Json.Decode.Decoder NixOSChannels
@ -188,7 +200,6 @@ decodeNixOSChannels =
(Json.Decode.field "channels" (Json.Decode.list decodeNixOSChannel)) (Json.Decode.field "channels" (Json.Decode.list decodeNixOSChannel))
decodeNixOSChannel : Json.Decode.Decoder NixOSChannel decodeNixOSChannel : Json.Decode.Decoder NixOSChannel
decodeNixOSChannel = decodeNixOSChannel =
Json.Decode.map4 NixOSChannel Json.Decode.map4 NixOSChannel
@ -201,11 +212,14 @@ decodeNixOSChannel =
"rolling" -> "rolling" ->
Json.Decode.succeed Rolling Json.Decode.succeed Rolling
"beta" ->
Json.Decode.succeed Beta
"stable" -> "stable" ->
Json.Decode.succeed Stable Json.Decode.succeed Stable
"beta" -> "deprecated" ->
Json.Decode.succeed Beta Json.Decode.succeed Deprecated
_ -> _ ->
Json.Decode.fail ("Unknown status: " ++ status) Json.Decode.fail ("Unknown status: " ++ status)
@ -983,7 +997,7 @@ viewChannels nixosChannels outMsg selectedChannel =
] ]
, onClick <| outMsg (ChannelChange channel.id) , onClick <| outMsg (ChannelChange channel.id)
] ]
[ text <| channelTitle channel ] (List.intersperse (text " ") ([ text channel.id ] ++ channelBadge channel.status))
) )
nixosChannels nixosChannels
) )