Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Commit d04433b

Browse files
committed
Remove out of context App bits
1 parent ed9f8f8 commit d04433b

File tree

4 files changed

+71
-221
lines changed

4 files changed

+71
-221
lines changed

src/UnisonLocal/App.elm

Lines changed: 27 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Browser.Navigation as Nav
66
import CodebaseTree
77
import Definition.Reference exposing (Reference)
88
import Env exposing (Env, OperatingSystem(..))
9-
import Env.AppContext as AppContext exposing (AppContext(..))
109
import Finder
1110
import Finder.SearchOptions as SearchOptions
1211
import FullyQualifiedName as FQN exposing (FQN)
@@ -24,15 +23,12 @@ import RemoteData
2423
import Route exposing (Route)
2524
import UI
2625
import UI.AppHeader as AppHeader
27-
import UI.Banner as Banner
2826
import UI.Button as Button
2927
import UI.Click as Click exposing (Click(..))
30-
import UI.CopyField as CopyField
3128
import UI.Icon as Icon
3229
import UI.Modal as Modal
3330
import UI.Sidebar as Sidebar
3431
import UI.Tooltip as Tooltip
35-
import UnisonShare.SidebarContent
3632
import Url exposing (Url)
3733
import Workspace
3834
import Workspace.WorkspaceItems as WorkspaceItems
@@ -48,7 +44,6 @@ type Modal
4844
| HelpModal
4945
| ReportBugModal
5046
| PublishModal
51-
| DownloadModal FQN
5247

5348

5449
type alias Model =
@@ -459,8 +454,8 @@ subscriptions model =
459454
-- VIEW
460455

461456

462-
appTitle : Maybe msg -> AppContext -> AppHeader.AppTitle msg
463-
appTitle clickMsg appContext =
457+
appTitle : Maybe msg -> AppHeader.AppTitle msg
458+
appTitle clickMsg =
464459
let
465460
appTitle_ =
466461
case clickMsg of
@@ -469,52 +464,28 @@ appTitle clickMsg appContext =
469464

470465
Just msg ->
471466
AppHeader.Clickable msg
472-
473-
content =
474-
case appContext of
475-
UnisonLocal ->
476-
h1 [] [ text "Unison", span [ class "context unison-local" ] [ text "Local" ] ]
477-
478-
UnisonShare ->
479-
h1 [] [ text "Unison", span [ class "context unison-share" ] [ text "Share" ] ]
480467
in
481-
appTitle_ content
468+
appTitle_ (h1 [] [ text "Unison", span [ class "context unison-local" ] [ text "Local" ] ])
482469

483470

484471
viewAppHeader : Model -> Html Msg
485472
viewAppHeader model =
486473
let
487-
{ appContext, perspective } =
488-
model.env
489-
490474
changePerspectiveMsg =
491-
case perspective of
475+
case model.env.perspective of
492476
Codebase codebaseHash ->
493477
ChangePerspective (Codebase codebaseHash)
494478

495479
Namespace { codebaseHash } ->
496480
ChangePerspective (Codebase codebaseHash)
497481

498482
appTitle_ =
499-
appTitle (Just changePerspectiveMsg) appContext
500-
501-
banner =
502-
case appContext of
503-
UnisonLocal ->
504-
Nothing
505-
506-
UnisonShare ->
507-
Just
508-
(Banner.promotion "article"
509-
"New Article: Spark-like distributed datasets in under 100 lines of Unison"
510-
(ExternalHref "https://www.unison-lang.org/articles/distributed-datasets/")
511-
"Check it out!"
512-
)
483+
appTitle (Just changePerspectiveMsg)
513484
in
514485
AppHeader.view
515486
{ menuToggle = Just ToggleSidebar
516487
, appTitle = appTitle_
517-
, banner = banner
488+
, banner = Nothing
518489
, rightButton = Just (Button.button (ShowModal PublishModal) "Publish on Unison Share" |> Button.share)
519490
}
520491

@@ -533,26 +504,13 @@ viewSidebarHeader env =
533504
-- thats quite involved...
534505
isOverflowing =
535506
fqn |> FQN.toString |> String.length |> (\l -> l > 20)
536-
537-
download =
538-
case env.appContext of
539-
UnisonShare ->
540-
Button.iconThenLabel (ShowModal (DownloadModal fqn)) Icon.download "Download latest version"
541-
|> Button.small
542-
|> Button.view
543-
|> List.singleton
544-
|> Sidebar.headerItem []
545-
546-
UnisonLocal ->
547-
UI.nothing
548507
in
549508
Sidebar.header
550509
[ Sidebar.headerItem
551510
[ classList [ ( "is-overflowing", isOverflowing ) ] ]
552511
[ UI.namespaceSlug
553512
, h2 [ class "namespace" ] [ FQN.view fqn ]
554513
]
555-
, download
556514
, UI.divider
557515
]
558516

@@ -573,67 +531,44 @@ viewMainSidebarCollapseButton model =
573531
]
574532

575533

576-
subMenu : AppContext -> List ( String, Click Msg )
577-
subMenu appContext =
534+
subMenu : List ( String, Click Msg )
535+
subMenu =
578536
[ ( "Unison website", ExternalHref "https://unisonweb.org" )
579537
, ( "Docs", ExternalHref "https://unisonweb.org/docs" )
580538
, ( "Language Reference", ExternalHref "https://unisonweb.org/docs/language-reference" )
581539
, ( "Community", ExternalHref "https://unisonweb.org/community" )
582540
, ( "Report a bug", OnClick (ShowModal ReportBugModal) )
541+
, ( "Unison Share", ExternalHref "https://share.unison-lang.org" )
583542
]
584-
++ (if AppContext.isUnisonLocal appContext then
585-
[ ( "Unison Share", ExternalHref "https://share.unison-lang.org" ) ]
586-
587-
else
588-
[]
589-
)
590543

591544

592-
unisonSubmenu : AppContext -> Html Msg
593-
unisonSubmenu appContext =
545+
unisonSubmenu : Html Msg
546+
unisonSubmenu =
594547
Tooltip.tooltip
595548
(Icon.unisonMark
596549
|> Icon.withClass "sidebar-unison-submenu"
597550
|> Icon.view
598551
)
599-
(subMenu appContext |> Tooltip.textMenu)
552+
(Tooltip.textMenu subMenu)
600553
|> Tooltip.withPosition Tooltip.RightOf
601554
|> Tooltip.withArrow Tooltip.End
602555
|> Tooltip.view
603556

604557

605558
viewMainSidebar : Model -> Html Msg
606559
viewMainSidebar model =
607-
let
608-
perspective =
609-
model.env.perspective
610-
611-
appContext =
612-
model.env.appContext
613-
614-
changePerspectiveMsg =
615-
Perspective.toNamespacePerspective perspective >> ChangePerspective
616-
617-
sidebarContent =
618-
if Perspective.isCodebasePerspective perspective && AppContext.isUnisonShare appContext then
619-
UnisonShare.SidebarContent.view changePerspectiveMsg
620-
621-
else
622-
UI.nothing
623-
in
624560
Sidebar.view
625561
[ viewMainSidebarCollapseButton model
626562
, div [ class "expanded-content" ]
627563
[ viewSidebarHeader model.env
628564
, div [ class "sidebar-scroll-area" ]
629-
[ sidebarContent
630-
, Sidebar.section
565+
[ Sidebar.section
631566
"Namespaces and Definitions"
632567
[ Html.map CodebaseTreeMsg (CodebaseTree.view model.codebaseTree) ]
633568
, nav []
634569
(List.map
635570
(\( l, c ) -> Click.view [] [ text l ] c)
636-
(subMenu appContext)
571+
subMenu
637572
++ [ a [ class "show-help", onClick (ShowModal HelpModal) ]
638573
[ text "Keyboard Shortcuts"
639574
, KeyboardShortcut.view model.keyboardShortcut (KeyboardShortcut.single QuestionMark)
@@ -643,7 +578,7 @@ viewMainSidebar model =
643578
]
644579
]
645580
, div [ class "collapsed-content" ]
646-
[ unisonSubmenu appContext
581+
[ unisonSubmenu
647582
, Tooltip.tooltip
648583
(a
649584
[ class "show-help-collapsed", onClick (ShowModal HelpModal) ]
@@ -658,33 +593,6 @@ viewMainSidebar model =
658593
]
659594

660595

661-
viewDownloadModal : FQN -> Html Msg
662-
viewDownloadModal fqn =
663-
let
664-
prettyName =
665-
FQN.toString fqn
666-
667-
unqualified =
668-
FQN.unqualifiedName fqn
669-
670-
pullCommand =
671-
"pull [email protected]:unisonweb/share.git:." ++ prettyName ++ " ." ++ unqualified
672-
673-
content =
674-
Modal.Content
675-
(section
676-
[]
677-
[ p [] [ text "Download ", UI.bold prettyName, text " by pulling the namespace from Unison Share into a namespace in your local codebase:" ]
678-
, CopyField.copyField (\_ -> CloseModal) pullCommand |> CopyField.withPrefix ".>" |> CopyField.view
679-
, div [ class "hint" ] [ text "Copy and paste this command into UCM." ]
680-
]
681-
)
682-
in
683-
Modal.modal "download-modal" CloseModal content
684-
|> Modal.withHeader ("Download " ++ prettyName)
685-
|> Modal.view
686-
687-
688596
viewHelpModal : OperatingSystem -> KeyboardShortcut.Model -> Html Msg
689597
viewHelpModal os keyboardShortcut =
690598
let
@@ -780,8 +688,8 @@ viewPublishModal =
780688
|> Modal.view
781689

782690

783-
viewReportBugModal : AppContext -> Html Msg
784-
viewReportBugModal appContext =
691+
viewReportBugModal : Html Msg
692+
viewReportBugModal =
785693
let
786694
content =
787695
Modal.Content
@@ -796,7 +704,7 @@ viewReportBugModal appContext =
796704
, div [ class "action" ]
797705
[ githubLinkButton "unisonweb/codebase-ui"
798706
, text "for reports on"
799-
, strong [] [ text (AppContext.toString appContext) ]
707+
, strong [] [ text "Unison Local" ]
800708
, span [ class "subtle" ] [ text "(this UI)" ]
801709
]
802710
, div [ class "action" ]
@@ -832,44 +740,34 @@ viewModal model =
832740
viewPublishModal
833741

834742
ReportBugModal ->
835-
viewReportBugModal model.env.appContext
743+
viewReportBugModal
836744

837-
DownloadModal fqn ->
838-
viewDownloadModal fqn
839745

840-
841-
viewAppLoading : AppContext -> Html msg
842-
viewAppLoading appContext =
746+
viewAppLoading : Html msg
747+
viewAppLoading =
843748
div [ id "app" ]
844-
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing appContext))
749+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
845750
, Sidebar.view []
846751
, div [ id "main-content" ] []
847752
]
848753

849754

850-
viewAppError : AppContext -> Http.Error -> Html msg
851-
viewAppError appContext error =
852-
let
853-
context =
854-
AppContext.toString appContext
855-
in
755+
viewAppError : Http.Error -> Html msg
756+
viewAppError error =
856757
div [ id "app" ]
857-
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing appContext))
758+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
858759
, Sidebar.view []
859760
, div [ id "main-content", class "app-error" ]
860761
[ Icon.view Icon.warn
861762
, p [ title (Api.errorToString error) ]
862-
[ text (context ++ " could not be started.") ]
763+
[ text "Unison Local could not be started." ]
863764
]
864765
]
865766

866767

867768
view : Model -> Browser.Document Msg
868769
view model =
869770
let
870-
title_ =
871-
AppContext.toString model.env.appContext
872-
873771
page =
874772
case model.route of
875773
Route.Perspective _ ->
@@ -882,7 +780,7 @@ view model =
882780
Route.Definition _ _ ->
883781
Html.map WorkspaceMsg (Workspace.view model.workspace)
884782
in
885-
{ title = title_
783+
{ title = "Unison Local"
886784
, body =
887785
[ div [ id "app", classList [ ( "sidebar-toggled", model.sidebarToggled ) ] ]
888786
[ viewAppHeader model

src/UnisonLocal/PreApp.elm

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Api exposing (ApiBasePath(..), ApiRequest)
44
import Browser
55
import Browser.Navigation as Nav
66
import Env exposing (Flags)
7-
import Env.AppContext as AppContext
87
import Html
98
import Http
109
import Perspective exposing (Perspective, PerspectiveParams)
@@ -120,19 +119,15 @@ subscriptions model =
120119

121120
view : Model -> Browser.Document Msg
122121
view model =
123-
let
124-
appContext flags =
125-
AppContext.fromString flags.appContext
126-
in
127122
case model of
128-
Initializing preEnv ->
123+
Initializing _ ->
129124
{ title = "Loading.."
130-
, body = [ App.viewAppLoading (appContext preEnv.flags) ]
125+
, body = [ App.viewAppLoading ]
131126
}
132127

133-
InitializationError preEnv error ->
128+
InitializationError _ error ->
134129
{ title = "Application Error"
135-
, body = [ App.viewAppError (appContext preEnv.flags) error ]
130+
, body = [ App.viewAppError error ]
136131
}
137132

138133
Initialized appModel ->

0 commit comments

Comments
 (0)