@@ -10,7 +10,7 @@ import Env.AppContext as AppContext exposing (AppContext(..))
1010import Finder
1111import Finder.SearchOptions as SearchOptions
1212import FullyQualifiedName as FQN exposing (FQN )
13- import Html exposing (Html , a , div , h1 , h2 , h3 , header , nav , p , section , span , strong , text )
13+ import Html exposing (Html , a , div , h1 , h2 , h3 , nav , p , section , span , strong , text )
1414import Html.Attributes exposing (class , classList , href , id , rel , target , title )
1515import Html.Events exposing (onClick )
1616import Http
@@ -27,6 +27,7 @@ import UI.AppHeader as AppHeader
2727import UI.Banner as Banner
2828import UI.Button as Button
2929import UI.Click as Click exposing (Click (..) )
30+ import UI.CopyField as CopyField
3031import UI.Icon as Icon
3132import UI.Modal as Modal
3233import UI.Sidebar as Sidebar
@@ -47,6 +48,7 @@ type Modal
4748 | HelpModal
4849 | ReportBugModal
4950 | PublishModal
51+ | DownloadModal FQN
5052
5153
5254type alias Model =
@@ -499,8 +501,8 @@ viewAppHeader model =
499501 }
500502
501503
502- viewPerspective : Env -> Html Msg
503- viewPerspective env =
504+ viewSidebarHeader : Env -> Html Msg
505+ viewSidebarHeader env =
504506 case env. perspective of
505507 Codebase _ ->
506508 UI . nothing
@@ -513,11 +515,27 @@ viewPerspective env =
513515 -- thats quite involved...
514516 isOverflowing =
515517 fqn |> FQN . toString |> String . length |> ( \ l -> l > 20 )
518+
519+ download =
520+ case env. appContext of
521+ UnisonShare ->
522+ Button . iconThenLabel ( ShowModal ( DownloadModal fqn)) Icon . download " Download latest version"
523+ |> Button . small
524+ |> Button . view
525+ |> List . singleton
526+ |> Sidebar . headerItem []
527+
528+ Ucm ->
529+ UI . nothing
516530 in
517- header
518- [ classList [ ( " perspective" , True ) , ( " is-overflowing" , isOverflowing ) ] ]
519- [ UI . namespaceSlug
520- , h2 [ class " namespace" ] [ FQN . view fqn ]
531+ Sidebar . header
532+ [ Sidebar . headerItem
533+ [ classList [ ( " is-overflowing" , isOverflowing ) ] ]
534+ [ UI . namespaceSlug
535+ , h2 [ class " namespace" ] [ FQN . view fqn ]
536+ ]
537+ , download
538+ , UI . divider
521539 ]
522540
523541
@@ -588,7 +606,7 @@ viewMainSidebar model =
588606 Sidebar . view
589607 [ viewMainSidebarCollapseButton model
590608 , div [ class " expanded-content" ]
591- [ viewPerspective model. env
609+ [ viewSidebarHeader model. env
592610 , div [ class " sidebar-scroll-area" ]
593611 [ sidebarContent
594612 , Sidebar . section
@@ -622,6 +640,33 @@ viewMainSidebar model =
622640 ]
623641
624642
643+ viewDownloadModal : FQN -> Html Msg
644+ viewDownloadModal fqn =
645+ let
646+ prettyName =
647+ FQN . toString fqn
648+
649+ unqualified =
650+ FQN . unqualifiedName fqn
651+
652+ pullCommand =
653+ " pull git@github.com:unisonweb/share.git:." ++ prettyName ++ " ." ++ unqualified
654+
655+ content =
656+ Modal . Content
657+ ( section
658+ []
659+ [ p [] [ text " Download " , UI . bold prettyName, text " by pulling the namespace from Unison Share into a namespace in your local codebase:" ]
660+ , CopyField . copyField ( \ _ -> CloseModal ) pullCommand |> CopyField . withPrefix " .>" |> CopyField . view
661+ , div [ class " hint" ] [ text " Copy and paste this command into UCM." ]
662+ ]
663+ )
664+ in
665+ Modal . modal " download-modal" CloseModal content
666+ |> Modal . withHeader ( " Download " ++ prettyName)
667+ |> Modal . view
668+
669+
625670viewHelpModal : OperatingSystem -> KeyboardShortcut .Model -> Html Msg
626671viewHelpModal os keyboardShortcut =
627672 let
@@ -771,6 +816,9 @@ viewModal model =
771816 ReportBugModal ->
772817 viewReportBugModal model. env. appContext
773818
819+ DownloadModal fqn ->
820+ viewDownloadModal fqn
821+
774822
775823viewAppLoading : AppContext -> Html msg
776824viewAppLoading appContext =
0 commit comments