Skip to content

Commit

Permalink
[FLORA-66] Signal deprecations and revision dates in version listing …
Browse files Browse the repository at this point in the history
…page (#548)

fixes #544
  • Loading branch information
tchoutri authored May 2, 2024
1 parent 65fee43 commit ca45fed
Show file tree
Hide file tree
Showing 7 changed files with 1,807 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.0.18 -- 2024-03-26

* Add @horizon namespace ([#498](https://github.com/flora-pm/flora-server/issues/498))
* Signal deprecations and revision dates in version listing page ([#548](https://github.com/flora-pm/flora-server/pull/548))

## 1.0.17 -- 2024-03-26

Expand Down
37 changes: 35 additions & 2 deletions src/web/FloraWeb/Pages/Templates/Packages.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
module FloraWeb.Pages.Templates.Packages where
module FloraWeb.Pages.Templates.Packages
( displayCategories
, displayDependencies
, displayDependents
, displayInstructions
, displayLicense
, displayLinks
, displayMaintainer
, displayNamespace
, displayPackageDeprecation
, displayPackageFlags
, displayReadme
, displayReleaseDeprecation
, displayReleaseVersion
, displayTestedWith
, displayVersions
, listVersions
, packageListing
, packageWithExecutableListing
, presentationHeaderForSubpage
, presentationHeaderForVersions
, showChangelog
, showDependencies
, showDependents
) where

import Control.Monad (when)
import Control.Monad.Extra (whenJust)
Expand Down Expand Up @@ -153,11 +177,20 @@ versionListItem namespace packageName release = do
a_ [href, class_ ""] $
do
h4_ [class_ "package-list-item__name"]
$ strong_ [class_ ""]
$ strong_ [class_ (if Just True == release.deprecated then " release-deprecated" else "")]
. toHtml
$ "v"
<> toHtml release.version
uploadedAt
case release.revisedAt of
Nothing -> span_ [] ""
Just revisionDate ->
span_
[ dataText_
("Revised on " <> display (Time.formatTime defaultTimeLocale "%a, %_d %b %Y, %R %EZ" revisionDate))
, class_ "revised-date"
]
Icon.pen
div_ [class_ "package-list-item__metadata"] $
span_ [class_ "package-list-item__license"] $
do
Expand Down
2 changes: 1 addition & 1 deletion test/Flora/PackageSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ testGetNonDeprecatedPackages = do
testReleaseDeprecation :: TestEff ()
testReleaseDeprecation = do
result <- Query.getHackagePackagesWithoutReleaseDeprecationInformation
assertEqual 69 (length result)
assertEqual 70 (length result)

binary <- fromJust <$> Query.getPackageByNamespaceAndName (Namespace "haskell") (PackageName "binary")
deprecatedBinaryVersion' <- assertJust =<< Query.getReleaseByVersion binary.packageId (mkVersion [0, 10, 0, 0])
Expand Down
2 changes: 0 additions & 2 deletions test/Flora/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ import Test.Tasty.HUnit qualified as Test

import Flora.Environment
import Flora.Environment.Config (LoggingDestination (..), PoolConfig (..))
import Flora.Import.Categories (importCategories)
import Flora.Import.Package.Bulk (importAllFilesInRelativeDirectory, importFromIndex)
import Flora.Logging qualified as Logging
import Flora.Model.BlobStore.API
Expand Down Expand Up @@ -311,7 +310,6 @@ testMigrations = do
pool <- getPool
liftIO $ withResource pool $ \conn ->
void $ runMigrations conn defaultOptions [MigrationInitialization, MigrationDirectory "./migrations"]
importCategories

genWord32 :: MonadGen m => m Word32
genWord32 = H.word32 (Range.constant minBound maxBound)
Expand Down
4 changes: 3 additions & 1 deletion test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Flora.BlobSpec qualified as BlobSpec
import Flora.CabalSpec qualified as CabalSpec
import Flora.CategorySpec qualified as CategorySpec
import Flora.Environment
import Flora.Import.Categories (importCategories)
import Flora.ImportSpec qualified as ImportSpec
import Flora.Model.PackageIndex.Update qualified as Update
import Flora.Model.User (UserCreationForm (..), mkUser)
Expand All @@ -31,13 +32,14 @@ main = do
fixtures <-
runTestEff
( do
testMigrations
cleanUp
importCategories
Update.createPackageIndex "hackage" "" "" Nothing
Update.createPackageIndex "cardano" "" "" Nothing
password <- liftIO $ Sel.hashText "foobar2000"
templateUser <- mkUser $ UserCreationForm "hackage-user" "tech@flora.pm" password
Update.insertUser templateUser
testMigrations
f' <- getFixtures
importAllPackages f'
pure f'
Expand Down
Loading

0 comments on commit ca45fed

Please sign in to comment.