Skip to content

Commit 808bb1c

Browse files
committed
Show latest release tag on project overview
1 parent 7353a80 commit 808bb1c

File tree

2 files changed

+95
-37
lines changed

2 files changed

+95
-37
lines changed

src/UnisonShare/Page/ProjectOverviewPage.elm

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import Code.Namespace.NamespaceRef as NamespaceRef
1010
import Code.Perspective as Perspective
1111
import Code.ProjectDependency as ProjectDependency exposing (ProjectDependency)
1212
import Code.ReadmeCard as ReadmeCard
13-
import Html exposing (Html, div, footer, form, p, span, strong, text)
13+
import Code.Version as Version exposing (Version)
14+
import Html exposing (Html, div, footer, form, header, p, span, strong, text)
1415
import Html.Attributes exposing (class)
1516
import Http exposing (Error)
1617
import Json.Decode as Decode
@@ -706,6 +707,26 @@ viewReadmeCard project readme =
706707
ReadmeCard.viewError RetryFetchReadme
707708

708709

710+
viewLatestVersion : ProjectRef -> Version -> Html msg
711+
viewLatestVersion projectRef version =
712+
div [ class "project-releases" ]
713+
[ header []
714+
[ strong [] [ text "Latest release" ]
715+
, span [ class "view-all" ]
716+
[ text " ("
717+
, Link.view "View all"
718+
(Link.projectReleases projectRef)
719+
, text ")"
720+
]
721+
]
722+
, Tag.tag (Version.toString version)
723+
|> Tag.withClick (Link.projectRelease projectRef version)
724+
|> Tag.withIcon Icon.rocket
725+
|> Tag.extraLarge
726+
|> Tag.view
727+
]
728+
729+
709730
viewDependencies : List ProjectDependency -> Html msg
710731
viewDependencies deps =
711732
let
@@ -732,7 +753,7 @@ viewDependencies deps =
732753
]
733754

734755

735-
view_ : Session -> ProjectDetails -> Model -> ( Maybe (List (Html Msg)), PageContent Msg )
756+
view_ : Session -> ProjectDetails -> Model -> ( List (Html Msg), PageContent Msg )
736757
view_ session project model =
737758
let
738759
viewKpi icon num labelSingular labelPlural kpiDescription =
@@ -843,17 +864,18 @@ view_ session project model =
843864
case ( project.summary, Set.toList project.tags ) of
844865
( Just s, [] ) ->
845866
Just
846-
[ div [ class "project-description" ]
867+
(div [ class "project-description" ]
847868
[ div [ class "project-summary" ] [ text s ]
848869
, edit Icon.writingPad "Edit summary"
849870
|> Maybe.map Button.view
850871
|> Maybe.withDefault UI.nothing
851872
]
852-
]
873+
)
853874

854875
( Just s, tags ) ->
855876
Just
856-
[ div [ class "project-description" ]
877+
(div
878+
[ class "project-description" ]
857879
[ div [ class "project-summary" ] [ text s ]
858880
, tags |> List.map Tag.tag |> Tag.viewTags
859881
, Button.icon ShowEditDescriptionModal Icon.writingPad
@@ -862,25 +884,27 @@ view_ session project model =
862884
|> showIfCanMaintain
863885
|> MaybeE.unwrap UI.nothing Button.view
864886
]
865-
]
887+
)
866888

867889
( Nothing, [] ) ->
868890
if canMaintain then
869891
Just
870-
[ div [ class "project-description-empty-state" ]
892+
(div
893+
[ class "project-description-empty-state" ]
871894
[ text "Add a bit of detail with a summary."
872895
, edit Icon.writingPad "Add now "
873896
|> MaybeE.unwrap UI.nothing Button.view
874897
]
875-
]
898+
)
876899

877900
else
878901
Nothing
879902

880903
( Nothing, tags ) ->
881904
if canMaintain then
882905
Just
883-
[ div []
906+
(div
907+
[]
884908
[ div
885909
[ class "project-description-empty-state" ]
886910
[ text "Add a bit of detail with a summary."
@@ -889,31 +913,26 @@ view_ session project model =
889913
]
890914
, tags |> List.map Tag.tag |> Tag.viewTags
891915
]
892-
]
916+
)
893917

894918
else
895919
Just
896-
[ div [] [ tags |> List.map Tag.tag |> Tag.viewTags ]
897-
]
920+
(div
921+
[]
922+
[ tags |> List.map Tag.tag |> Tag.viewTags ]
923+
)
898924

899925
dependencies =
900926
model.dependencies
901927
|> RemoteData.toMaybe
902928
|> Maybe.map viewDependencies
903929

904-
aside =
905-
case ( summaryAndTags, dependencies ) of
906-
( Just sumAndTags, Just deps ) ->
907-
Just (sumAndTags ++ [ deps ])
908-
909-
( Nothing, Just deps ) ->
910-
Just [ deps ]
930+
version =
931+
project.latestVersion
932+
|> Maybe.map (viewLatestVersion project.ref)
911933

912-
( Just sumAndTags, Nothing ) ->
913-
Just sumAndTags
914-
915-
_ ->
916-
Nothing
934+
aside =
935+
MaybeE.values [ summaryAndTags, dependencies, version ]
917936

918937
content =
919938
PageContent.oneColumn
@@ -949,17 +968,16 @@ view session projectRef project model =
949968
( aside, content ) =
950969
view_ session project model
951970
in
952-
case aside of
953-
Just aside_ ->
954-
( PageLayout.centeredLayout (PageContent.withLeftAside aside_ content)
955-
PageFooter.pageFooter
956-
|> PageLayout.withSubduedBackground
957-
, modal
958-
)
971+
if List.isEmpty aside then
972+
( PageLayout.centeredNarrowLayout content
973+
PageFooter.pageFooter
974+
|> PageLayout.withSubduedBackground
975+
, modal
976+
)
959977

960-
Nothing ->
961-
( PageLayout.centeredNarrowLayout content
962-
PageFooter.pageFooter
963-
|> PageLayout.withSubduedBackground
964-
, modal
965-
)
978+
else
979+
( PageLayout.centeredLayout (PageContent.withLeftAside aside content)
980+
PageFooter.pageFooter
981+
|> PageLayout.withSubduedBackground
982+
, modal
983+
)

src/css/unison-share/page/project-overview-page.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,33 @@
163163
border: 1px solid var(--u-color_border);
164164
}
165165

166+
.project-overview-page .project-releases {
167+
display: flex;
168+
flex-direction: column;
169+
gap: 0.5rem;
170+
171+
.view-all {
172+
font-size: var(--font-size-small);
173+
}
174+
175+
.tag {
176+
background: var(--c-color_tag_bg);
177+
font-weight: bold;
178+
font-family: var(--font-monospace);
179+
border: 1px solid var(--u-color_border_subdued);
180+
}
181+
182+
a.tag {
183+
background: var(--u-color_element);
184+
border: 1px solid var(--u-color_border);
185+
}
186+
187+
a.tag:hover {
188+
background: var(--c-color_tag_bg_hovered);
189+
border: 1px solid var(--u-color_border);
190+
}
191+
}
192+
166193
#project-readme-instructions-modal {
167194
width: 34.5rem;
168195
}
@@ -206,4 +233,17 @@
206233
.project-overview-page .project-dependencies {
207234
display: none;
208235
}
236+
237+
.project-overview-page .project-releases {
238+
flex-direction: row;
239+
line-height: 1;
240+
align-items: center;
241+
242+
.tag {
243+
margin-top: 2px;
244+
font-size: var(--font-size-small);
245+
height: 1.5rem;
246+
padding: 0 0.5rem;
247+
}
248+
}
209249
}

0 commit comments

Comments
 (0)