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

Commit baddff0

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

File tree

4 files changed

+61
-203
lines changed

4 files changed

+61
-203
lines changed

src/UnisonLocal/App.elm

Lines changed: 22 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ import RemoteData
2424
import Route exposing (Route)
2525
import UI
2626
import UI.AppHeader as AppHeader
27-
import UI.Banner as Banner
2827
import UI.Button as Button
2928
import UI.Click as Click exposing (Click(..))
30-
import UI.CopyField as CopyField
3129
import UI.Icon as Icon
3230
import UI.Modal as Modal
3331
import UI.Sidebar as Sidebar
3432
import UI.Tooltip as Tooltip
35-
import UnisonShare.SidebarContent
3633
import Url exposing (Url)
3734
import Workspace
3835
import Workspace.WorkspaceItems as WorkspaceItems
@@ -48,7 +45,6 @@ type Modal
4845
| HelpModal
4946
| ReportBugModal
5047
| PublishModal
51-
| DownloadModal FQN
5248

5349

5450
type alias Model =
@@ -459,8 +455,8 @@ subscriptions model =
459455
-- VIEW
460456

461457

462-
appTitle : Maybe msg -> AppContext -> AppHeader.AppTitle msg
463-
appTitle clickMsg appContext =
458+
appTitle : Maybe msg -> AppHeader.AppTitle msg
459+
appTitle clickMsg =
464460
let
465461
appTitle_ =
466462
case clickMsg of
@@ -469,52 +465,28 @@ appTitle clickMsg appContext =
469465

470466
Just msg ->
471467
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" ] ]
480468
in
481-
appTitle_ content
469+
appTitle_ (h1 [] [ text "Unison", span [ class "context unison-local" ] [ text "Local" ] ])
482470

483471

484472
viewAppHeader : Model -> Html Msg
485473
viewAppHeader model =
486474
let
487-
{ appContext, perspective } =
488-
model.env
489-
490475
changePerspectiveMsg =
491-
case perspective of
476+
case model.env.perspective of
492477
Codebase codebaseHash ->
493478
ChangePerspective (Codebase codebaseHash)
494479

495480
Namespace { codebaseHash } ->
496481
ChangePerspective (Codebase codebaseHash)
497482

498483
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-
)
484+
appTitle (Just changePerspectiveMsg)
513485
in
514486
AppHeader.view
515487
{ menuToggle = Just ToggleSidebar
516488
, appTitle = appTitle_
517-
, banner = banner
489+
, banner = Nothing
518490
, rightButton = Just (Button.button (ShowModal PublishModal) "Publish on Unison Share" |> Button.share)
519491
}
520492

@@ -533,26 +505,13 @@ viewSidebarHeader env =
533505
-- thats quite involved...
534506
isOverflowing =
535507
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
548508
in
549509
Sidebar.header
550510
[ Sidebar.headerItem
551511
[ classList [ ( "is-overflowing", isOverflowing ) ] ]
552512
[ UI.namespaceSlug
553513
, h2 [ class "namespace" ] [ FQN.view fqn ]
554514
]
555-
, download
556515
, UI.divider
557516
]
558517

@@ -573,67 +532,44 @@ viewMainSidebarCollapseButton model =
573532
]
574533

575534

576-
subMenu : AppContext -> List ( String, Click Msg )
577-
subMenu appContext =
535+
subMenu : List ( String, Click Msg )
536+
subMenu =
578537
[ ( "Unison website", ExternalHref "https://unisonweb.org" )
579538
, ( "Docs", ExternalHref "https://unisonweb.org/docs" )
580539
, ( "Language Reference", ExternalHref "https://unisonweb.org/docs/language-reference" )
581540
, ( "Community", ExternalHref "https://unisonweb.org/community" )
582541
, ( "Report a bug", OnClick (ShowModal ReportBugModal) )
542+
, ( "Unison Share", ExternalHref "https://share.unison-lang.org" )
583543
]
584-
++ (if AppContext.isUnisonLocal appContext then
585-
[ ( "Unison Share", ExternalHref "https://share.unison-lang.org" ) ]
586-
587-
else
588-
[]
589-
)
590544

591545

592-
unisonSubmenu : AppContext -> Html Msg
593-
unisonSubmenu appContext =
546+
unisonSubmenu : Html Msg
547+
unisonSubmenu =
594548
Tooltip.tooltip
595549
(Icon.unisonMark
596550
|> Icon.withClass "sidebar-unison-submenu"
597551
|> Icon.view
598552
)
599-
(subMenu appContext |> Tooltip.textMenu)
553+
(Tooltip.textMenu subMenu)
600554
|> Tooltip.withPosition Tooltip.RightOf
601555
|> Tooltip.withArrow Tooltip.End
602556
|> Tooltip.view
603557

604558

605559
viewMainSidebar : Model -> Html Msg
606560
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
624561
Sidebar.view
625562
[ viewMainSidebarCollapseButton model
626563
, div [ class "expanded-content" ]
627564
[ viewSidebarHeader model.env
628565
, div [ class "sidebar-scroll-area" ]
629-
[ sidebarContent
630-
, Sidebar.section
566+
[ Sidebar.section
631567
"Namespaces and Definitions"
632568
[ Html.map CodebaseTreeMsg (CodebaseTree.view model.codebaseTree) ]
633569
, nav []
634570
(List.map
635571
(\( l, c ) -> Click.view [] [ text l ] c)
636-
(subMenu appContext)
572+
subMenu
637573
++ [ a [ class "show-help", onClick (ShowModal HelpModal) ]
638574
[ text "Keyboard Shortcuts"
639575
, KeyboardShortcut.view model.keyboardShortcut (KeyboardShortcut.single QuestionMark)
@@ -643,7 +579,7 @@ viewMainSidebar model =
643579
]
644580
]
645581
, div [ class "collapsed-content" ]
646-
[ unisonSubmenu appContext
582+
[ unisonSubmenu
647583
, Tooltip.tooltip
648584
(a
649585
[ class "show-help-collapsed", onClick (ShowModal HelpModal) ]
@@ -658,33 +594,6 @@ viewMainSidebar model =
658594
]
659595

660596

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-
688597
viewHelpModal : OperatingSystem -> KeyboardShortcut.Model -> Html Msg
689598
viewHelpModal os keyboardShortcut =
690599
let
@@ -834,32 +743,25 @@ viewModal model =
834743
ReportBugModal ->
835744
viewReportBugModal model.env.appContext
836745

837-
DownloadModal fqn ->
838-
viewDownloadModal fqn
839-
840746

841-
viewAppLoading : AppContext -> Html msg
842-
viewAppLoading appContext =
747+
viewAppLoading : Html msg
748+
viewAppLoading =
843749
div [ id "app" ]
844-
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing appContext))
750+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
845751
, Sidebar.view []
846752
, div [ id "main-content" ] []
847753
]
848754

849755

850-
viewAppError : AppContext -> Http.Error -> Html msg
851-
viewAppError appContext error =
852-
let
853-
context =
854-
AppContext.toString appContext
855-
in
756+
viewAppError : Http.Error -> Html msg
757+
viewAppError error =
856758
div [ id "app" ]
857-
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing appContext))
759+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
858760
, Sidebar.view []
859761
, div [ id "main-content", class "app-error" ]
860762
[ Icon.view Icon.warn
861763
, p [ title (Api.errorToString error) ]
862-
[ text (context ++ " could not be started.") ]
764+
[ text "Unison Local could not be started." ]
863765
]
864766
]
865767

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)