Cleanup unused frontend code (#653)

* frontend: remove unnecessary imports & js files

* frontend: cleanup code with elm-review - remove unused code

* frontend: remove duplicate viewport
This commit is contained in:
Marco Daniel Martins 2023-05-04 14:51:19 +02:00 committed by GitHub
parent 0d663f27fa
commit 0498effc41
Failed to generate hash of commit
8 changed files with 19 additions and 114 deletions

View file

@ -28,15 +28,13 @@ import Html.Attributes
)
import Json.Decode
import Page.Flakes exposing (Model(..))
import Page.Home
import Page.Options
import Page.Packages
import RemoteData exposing (RemoteData(..))
import Route exposing (SearchType(..))
import Search
exposing
( Msg(..)
, NixOSChannel
( NixOSChannel
, decodeNixOSChannels
, defaultFlakeId
)
@ -68,7 +66,6 @@ type alias Model =
type Page
= NotFound
| Home Page.Home.Model
| Packages Page.Packages.Model
| Options Page.Options.Model
| Flakes Page.Flakes.Model
@ -113,7 +110,6 @@ init flags url navKey =
type Msg
= ChangedUrl Url.Url
| ClickedLink Browser.UrlRequest
| HomeMsg Page.Home.Msg
| PackagesMsg Page.Packages.Msg
| OptionsMsg Page.Options.Msg
| FlakesMsg Page.Flakes.Msg
@ -199,9 +195,6 @@ pageMatch m1 m2 =
( NotFound, NotFound ) ->
True
( Home _, Home _ ) ->
True
( Packages model_a, Packages model_b ) ->
{ model_a | show = Nothing, showInstallDetails = Search.Unset, result = NotAsked }
== { model_b | show = Nothing, showInstallDetails = Search.Unset, result = NotAsked }
@ -321,10 +314,6 @@ update msg model =
( ChangedUrl url, _ ) ->
changeRouteTo model url
( HomeMsg subMsg, Home subModel ) ->
Page.Home.update subMsg subModel model.nixosChannels
|> updateWith Home HomeMsg model
( PackagesMsg subMsg, Packages subModel ) ->
Page.Packages.update model.navKey subMsg subModel model.nixosChannels
|> updateWith Packages PackagesMsg model
@ -337,7 +326,7 @@ update msg model =
Page.Flakes.update model.navKey subMsg subModel model.nixosChannels
|> updateWith Flakes FlakesMsg model
( _, _ ) ->
_ ->
-- Disregard messages that arrived for the wrong page.
( model, Cmd.none )
@ -455,9 +444,6 @@ viewPage model =
NotFound ->
div [] [ text "Not Found" ]
Home _ ->
div [] [ text "Welcome" ]
Packages packagesModel ->
Html.map (\m -> PackagesMsg m) <| Page.Packages.view model.nixosChannels packagesModel

View file

@ -26,11 +26,10 @@ import Html.Events exposing (onClick)
import Http exposing (Body)
import Page.Options exposing (Msg(..))
import Page.Packages exposing (Msg(..))
import RemoteData exposing (RemoteData(..))
import RemoteData
import Route
exposing
( Route(..)
, SearchType(..)
( SearchType(..)
)
import Search
exposing

View file

@ -1,45 +0,0 @@
module Page.Home exposing (Model, Msg, init, update, view)
import Html exposing (Html, div, text)
import Search exposing (NixOSChannel)
-- MODEL
type alias Model =
()
init : ( Model, Cmd Msg )
init =
( (), Cmd.none )
-- UPDATE
type Msg
= NoOp
update :
Msg
-> Model
-> List NixOSChannel
-> ( Model, Cmd Msg )
update msg model _ =
case msg of
NoOp ->
( model, Cmd.none )
-- VIEW
view : Model -> Html Msg
view _ =
div [] [ text "Home" ]

View file

@ -3,9 +3,7 @@ module Page.Packages exposing
, Msg(..)
, decodeResultAggregations
, decodeResultItemSource
, encodeBuckets
, init
, initBuckets
, makeRequest
, makeRequestBody
, update
@ -14,7 +12,6 @@ module Page.Packages exposing
, viewSuccess
)
import Browser.Events exposing (Visibility(..))
import Browser.Navigation
import Html
exposing
@ -47,12 +44,11 @@ import Json.Decode.Pipeline
import Json.Encode
import Maybe
import Regex
import Route exposing (Route(..), SearchType)
import Route exposing (SearchType)
import Search
exposing
( Details(..)
( Details
, NixOSChannel
, decodeResolvedFlake
, viewBucket
)
import Utils

View file

@ -6,13 +6,10 @@ module Route exposing
, allTypes
, fromUrl
, href
, replaceUrl
, routeToString
, searchTypeToString
, searchTypeToTitle
)
import Browser.Navigation
import Html
import Html.Attributes
import Route.SearchQuery exposing (SearchQuery)
@ -164,11 +161,6 @@ href targetRoute =
Html.Attributes.href (routeToString targetRoute)
replaceUrl : Browser.Navigation.Key -> Route -> Cmd msg
replaceUrl navKey route =
Browser.Navigation.replaceUrl navKey (routeToString route)
fromUrl : Url.Url -> Maybe Route
fromUrl url =
-- The RealWorld spec treats the fragment like a path.

View file

@ -11,14 +11,11 @@ module Search exposing
, ResultItem
, SearchResult
, Sort(..)
, closeButton
, decodeAggregation
, decodeNixOSChannels
, decodeResolvedFlake
, decodeResult
, defaultFlakeId
, elementId
, fromSortId
, init
, makeRequest
, makeRequestBody
@ -36,7 +33,6 @@ module Search exposing
import Base64
import Browser.Dom
import Browser.Events exposing (Visibility(..))
import Browser.Navigation
import Html
exposing
@ -379,7 +375,6 @@ type Msg a b
| ToggleSort
| BucketsChange String
| ChannelChange String
| FlakeChange String
| SubjectChange SearchType
| QueryInput String
| QueryInputSubmit
@ -464,16 +459,6 @@ update toRoute navKey msg model nixosChannels =
|> ensureLoading nixosChannels
|> pushUrl toRoute navKey
FlakeChange flake ->
{ model
| channel = flake
, show = Nothing
, buckets = Nothing
, from = 0
}
|> ensureLoading nixosChannels
|> pushUrl toRoute navKey
SubjectChange subject ->
{ model
| searchType = subject

View file

@ -2,29 +2,22 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NixOS Search</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NixOS Search</title>
<script type="text/javascript" src="https://nixos.org/js/jquery.min.js"></script>
<link rel="stylesheet" href="https://nixos.org/bootstrap/css/bootstrap.min.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://nixos.org/bootstrap/css/bootstrap-responsive.min.css"/>
<script type="text/javascript" src="https://nixos.org/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://nixos.org/bootstrap/css/bootstrap.min.css" />
<link rel="shortcut icon" type="image/png" href="https://nixos.org/favicon.png"/>
<link rel="stylesheet" href="https://nixos.org/bootstrap/css/bootstrap-responsive.min.css" />
<link rel="shortcut icon" type="image/png" href="https://nixos.org/favicon.png" />
<link rel="search" type="application/opensearchdescription+xml" title="NixOS packages"
href="/desc-search-packages.xml">
<link rel="search" type="application/opensearchdescription+xml" title="NixOS options" href="/desc-search-options.xml">
<link rel="search" type="application/opensearchdescription+xml" title="NixOS packages"
href="/desc-search-packages.xml">
<link rel="search" type="application/opensearchdescription+xml" title="NixOS options"
href="/desc-search-options.xml">
</head>
<body>
<script src="https://nixos.org/js/jquery.min.js"></script>
<script src="https://nixos.org/bootstrap/js/bootstrap.min.js"></script>
</body>
<body></body>
</html>

View file

@ -1,8 +1,7 @@
module Example exposing (fuzzTest, unitTest, viewTest)
import Expect exposing (Expectation)
import Fuzz exposing (Fuzzer, int, list, string)
import Main exposing (..)
import Expect
import Fuzz exposing (int)
import Test exposing (..)
import Test.Html.Query as Query
import Test.Html.Selector exposing (tag, text)