This repository was archived by the owner on Jul 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathApp.elm
799 lines (650 loc) · 26.3 KB
/
App.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
module UnisonLocal.App exposing (..)
import Api
import Browser
import Browser.Navigation as Nav
import CodebaseTree
import Definition.Reference exposing (Reference)
import Env exposing (Env, OperatingSystem(..))
import Finder
import Finder.SearchOptions as SearchOptions
import FullyQualifiedName as FQN exposing (FQN)
import Html exposing (Html, a, div, h1, h2, h3, nav, p, section, span, strong, text)
import Html.Attributes exposing (class, classList, href, id, rel, target, title)
import Html.Events exposing (onClick)
import Http
import KeyboardShortcut
import KeyboardShortcut.Key as Key exposing (Key(..))
import KeyboardShortcut.KeyboardEvent as KeyboardEvent exposing (KeyboardEvent)
import Namespace exposing (NamespaceDetails)
import Perspective exposing (Perspective(..))
import PerspectiveLanding
import RemoteData
import UI
import UI.AppHeader as AppHeader
import UI.Button as Button
import UI.Click as Click exposing (Click(..))
import UI.Icon as Icon
import UI.Modal as Modal
import UI.PageLayout as PageLayout
import UI.Sidebar as Sidebar
import UI.Tooltip as Tooltip
import UnisonLocal.Route as Route exposing (Route)
import Url exposing (Url)
import Workspace
import Workspace.WorkspaceItems as WorkspaceItems
-- MODEL
type Modal
= NoModal
| FinderModal Finder.Model
| HelpModal
| ReportBugModal
| PublishModal
type alias Model =
{ route : Route
, codebaseTree : CodebaseTree.Model
, workspace : Workspace.Model
, perspectiveLanding : PerspectiveLanding.Model
, modal : Modal
, keyboardShortcut : KeyboardShortcut.Model
, env : Env
-- This is called "toggled" and not "hidden" because the behavior of
-- toggling the sidebar on/off is inverse on mobile vs desktop
, sidebarToggled : Bool
}
init : Env -> Route -> ( Model, Cmd Msg )
init env route =
let
( workspace, workspaceCmd ) =
case route of
Route.Definition _ ref ->
Workspace.init env (Just ref)
_ ->
Workspace.init env Nothing
( codebaseTree, codebaseTreeCmd ) =
CodebaseTree.init env
fetchNamespaceDetailsCmd =
env.perspective
|> fetchNamespaceDetails
|> Maybe.map (Api.perform env.apiBasePath)
|> Maybe.withDefault Cmd.none
model =
{ route = route
, workspace = workspace
, perspectiveLanding = PerspectiveLanding.init
, codebaseTree = codebaseTree
, modal = NoModal
, keyboardShortcut = KeyboardShortcut.init env.operatingSystem
, env = env
, sidebarToggled = False
}
in
( model
, Cmd.batch
[ Cmd.map CodebaseTreeMsg codebaseTreeCmd
, Cmd.map WorkspaceMsg workspaceCmd
, fetchNamespaceDetailsCmd
]
)
-- UPDATE
type Msg
= LinkClicked Browser.UrlRequest
| UrlChanged Url
| ChangePerspective Perspective
| FetchPerspectiveNamespaceDetailsFinished FQN (Result Http.Error NamespaceDetails)
| Keydown KeyboardEvent
| OpenDefinition Reference
| ShowModal Modal
| CloseModal
| ToggleSidebar
-- sub msgs
| FinderMsg Finder.Msg
| WorkspaceMsg Workspace.Msg
| PerspectiveLandingMsg PerspectiveLanding.Msg
| CodebaseTreeMsg CodebaseTree.Msg
| KeyboardShortcutMsg KeyboardShortcut.Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg ({ env } as model) =
case msg of
LinkClicked urlRequest ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl env.navKey (Url.toString url) )
-- External links are handled via target blank and never end up
-- here
Browser.External _ ->
( model, Cmd.none )
UrlChanged url ->
let
route =
Route.fromUrl env.basePath url
model2 =
{ model | route = route }
newEnv params =
{ env | perspective = Perspective.nextFromParams env.perspective params }
in
case route of
Route.Definition params ref ->
let
( workspace, cmd ) =
Workspace.open (newEnv params) model.workspace ref
model3 =
{ model2 | workspace = workspace, env = newEnv params }
( model4, fetchPerspectiveCmd ) =
fetchPerspectiveAndCodebaseTree env.perspective model3
in
( model4, Cmd.batch [ Cmd.map WorkspaceMsg cmd, fetchPerspectiveCmd ] )
Route.Perspective params ->
fetchPerspectiveAndCodebaseTree env.perspective { model2 | env = newEnv params }
ChangePerspective perspective ->
navigateToPerspective model perspective
FetchPerspectiveNamespaceDetailsFinished fqn details ->
let
perspective =
case env.perspective of
Namespace p ->
if FQN.equals p.fqn fqn then
Namespace { p | details = RemoteData.fromResult details }
else
env.perspective
_ ->
env.perspective
nextEnv =
{ env | perspective = perspective }
in
( { model | env = nextEnv }, Cmd.none )
Keydown event ->
keydown model event
OpenDefinition ref ->
navigateToDefinition model ref
ShowModal modal ->
( { model | modal = modal }, Cmd.none )
CloseModal ->
( { model | modal = NoModal }, Cmd.none )
ToggleSidebar ->
( { model | sidebarToggled = not model.sidebarToggled }, Cmd.none )
-- Sub msgs
WorkspaceMsg wMsg ->
let
( workspace, wCmd, outMsg ) =
Workspace.update env wMsg model.workspace
model2 =
{ model | workspace = workspace }
( model3, cmd ) =
handleWorkspaceOutMsg model2 outMsg
in
( model3, Cmd.batch [ cmd, Cmd.map WorkspaceMsg wCmd ] )
PerspectiveLandingMsg rMsg ->
let
( perspectiveLanding, outMsg ) =
PerspectiveLanding.update rMsg model.perspectiveLanding
model2 =
{ model | perspectiveLanding = perspectiveLanding }
in
case outMsg of
PerspectiveLanding.OpenDefinition ref ->
navigateToDefinition model2 ref
PerspectiveLanding.ShowFinderRequest ->
showFinder model2 Nothing
PerspectiveLanding.None ->
( model2, Cmd.none )
CodebaseTreeMsg cMsg ->
let
( codebaseTree, cCmd, outMsg ) =
CodebaseTree.update env cMsg model.codebaseTree
model2 =
{ model | codebaseTree = codebaseTree }
( model3, cmd ) =
case outMsg of
CodebaseTree.None ->
( model2, Cmd.none )
CodebaseTree.OpenDefinition ref ->
-- reset sidebarToggled to close it on mobile, but keep it open on desktop
let
model4 =
{ model2 | sidebarToggled = False }
in
navigateToDefinition model4 ref
CodebaseTree.ChangePerspectiveToNamespace fqn ->
fqn
|> Perspective.toNamespacePerspective model.env.perspective
|> navigateToPerspective model
in
( model3, Cmd.batch [ cmd, Cmd.map CodebaseTreeMsg cCmd ] )
FinderMsg fMsg ->
case model.modal of
FinderModal fModel ->
let
( fm, fc, out ) =
Finder.update env fMsg fModel
in
case out of
Finder.Remain ->
( { model | modal = FinderModal fm }, Cmd.map FinderMsg fc )
Finder.Exit ->
( { model | modal = NoModal }, Cmd.none )
Finder.OpenDefinition ref ->
navigateToDefinition { model | modal = NoModal } ref
_ ->
( model, Cmd.none )
KeyboardShortcutMsg kMsg ->
let
( keyboardShortcut, cmd ) =
KeyboardShortcut.update kMsg model.keyboardShortcut
in
( { model | keyboardShortcut = keyboardShortcut }, Cmd.map KeyboardShortcutMsg cmd )
-- UPDATE HELPERS
navigateToDefinition : Model -> Reference -> ( Model, Cmd Msg )
navigateToDefinition model ref =
( model, Route.navigateToDefinition model.env.navKey model.route ref )
navigateToPerspective : Model -> Perspective -> ( Model, Cmd Msg )
navigateToPerspective model perspective =
let
-- Update all open references to be hash based to ensure that we can
-- refresh the page and fetch them appropriately even if they are
-- outside of the current perspective
workspace =
Workspace.replaceWorkspaceItemReferencesWithHashOnly model.workspace
-- Re-navigate to the currently open definition by hash
focusedReferenceRoute =
workspace.workspaceItems
|> WorkspaceItems.focusedReference
|> Maybe.map (Route.toDefinition model.route)
|> Maybe.withDefault model.route
changeRouteCmd =
Route.replacePerspective model.env.navKey (Perspective.toParams perspective) focusedReferenceRoute
in
( { model | workspace = workspace }, changeRouteCmd )
fetchPerspectiveAndCodebaseTree : Perspective -> Model -> ( Model, Cmd Msg )
fetchPerspectiveAndCodebaseTree oldPerspective ({ env } as model) =
let
( codebaseTree, codebaseTreeCmd ) =
CodebaseTree.init env
fetchNamespaceDetailsCmd =
env.perspective
|> fetchNamespaceDetails
|> Maybe.map (Api.perform env.apiBasePath)
|> Maybe.withDefault Cmd.none
in
if Perspective.needsFetching env.perspective then
( { model | codebaseTree = codebaseTree }
, Cmd.batch
[ Cmd.map CodebaseTreeMsg codebaseTreeCmd
, fetchNamespaceDetailsCmd
]
)
else if not (Perspective.equals oldPerspective env.perspective) then
( model, Cmd.map CodebaseTreeMsg codebaseTreeCmd )
else
( model, Cmd.none )
handleWorkspaceOutMsg : Model -> Workspace.OutMsg -> ( Model, Cmd Msg )
handleWorkspaceOutMsg ({ env } as model) out =
case out of
Workspace.None ->
( model, Cmd.none )
Workspace.ShowFinderRequest withinNamespace ->
showFinder model withinNamespace
Workspace.Focused ref ->
( model, Route.navigateToDefinition env.navKey model.route ref )
Workspace.Emptied ->
( model, Route.navigateToCurrentPerspective env.navKey model.route )
Workspace.ChangePerspectiveToNamespace fqn ->
fqn
|> Perspective.toNamespacePerspective model.env.perspective
|> navigateToPerspective model
keydown : Model -> KeyboardEvent -> ( Model, Cmd Msg )
keydown model keyboardEvent =
let
shortcut =
KeyboardShortcut.fromKeyboardEvent model.keyboardShortcut keyboardEvent
noOp =
( model, Cmd.none )
toggleSidebar =
( { model | sidebarToggled = not model.sidebarToggled }, Cmd.none )
in
case shortcut of
KeyboardShortcut.Chord Ctrl (B _) ->
toggleSidebar
KeyboardShortcut.Chord Meta (B _) ->
toggleSidebar
KeyboardShortcut.Chord Shift QuestionMark ->
( { model | modal = HelpModal }, Cmd.none )
KeyboardShortcut.Sequence _ Escape ->
if model.modal == HelpModal then
( { model | modal = NoModal }, Cmd.none )
else
noOp
_ ->
noOp
showFinder :
{ m | env : Env, modal : Modal }
-> Maybe FQN
-> ( { m | env : Env, modal : Modal }, Cmd Msg )
showFinder model withinNamespace =
let
options =
SearchOptions.init model.env.perspective withinNamespace
( fm, fcmd ) =
Finder.init model.env options
in
( { model | modal = FinderModal fm }, Cmd.map FinderMsg fcmd )
-- EFFECTS
fetchNamespaceDetails : Perspective -> Maybe (Api.ApiRequest NamespaceDetails Msg)
fetchNamespaceDetails perspective =
case perspective of
Namespace { fqn } ->
fqn
|> Api.namespace perspective
|> Api.toRequest Namespace.decodeDetails (FetchPerspectiveNamespaceDetailsFinished fqn)
|> Just
_ ->
Nothing
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.batch
[ KeyboardEvent.subscribe KeyboardEvent.Keydown Keydown
, Sub.map WorkspaceMsg (Workspace.subscriptions model.workspace)
]
-- VIEW
appTitle : Maybe msg -> AppHeader.AppTitle msg
appTitle clickMsg =
let
appTitle_ =
case clickMsg of
Nothing ->
AppHeader.Disabled
Just msg ->
AppHeader.Clickable msg
in
appTitle_ (h1 [] [ text "Unison", span [ class "context unison-local" ] [ text "Local" ] ])
viewAppHeader : Model -> AppHeader.AppHeader Msg
viewAppHeader model =
let
changePerspectiveMsg =
case model.env.perspective of
Codebase codebaseHash ->
ChangePerspective (Codebase codebaseHash)
Namespace { codebaseHash } ->
ChangePerspective (Codebase codebaseHash)
appTitle_ =
appTitle (Just changePerspectiveMsg)
in
{ menuToggle = Just ToggleSidebar
, appTitle = appTitle_
, banner = Nothing
, rightButton = Just (Button.button (ShowModal PublishModal) "Publish on Unison Share" |> Button.share)
}
viewSidebarHeader : Env -> Html Msg
viewSidebarHeader env =
case env.perspective of
Codebase _ ->
UI.nothing
Namespace { fqn } ->
let
-- Imprecise, but close enough, approximation of overflowing,
-- which results in a slight faded left edge A better way would
-- be to measure the DOM like we do for overflowing docs, but
-- thats quite involved...
isOverflowing =
fqn |> FQN.toString |> String.length |> (\l -> l > 20)
in
Sidebar.header
[ Sidebar.headerItem
[ classList [ ( "is-overflowing", isOverflowing ) ] ]
[ UI.namespaceSlug
, h2 [ class "namespace" ] [ FQN.view fqn ]
]
, UI.divider
]
viewMainSidebarCollapseButton : Model -> Html Msg
viewMainSidebarCollapseButton model =
div
[ class "collapse-sidebar-button" ]
[ Button.icon ToggleSidebar
(if model.sidebarToggled then
Icon.chevronRight
else
Icon.chevronLeft
)
|> Button.small
|> Button.view
]
subMenu : List ( String, Click Msg )
subMenu =
[ ( "Unison website", ExternalHref "https://unisonweb.org" )
, ( "Docs", ExternalHref "https://unisonweb.org/docs" )
, ( "Language Reference", ExternalHref "https://unisonweb.org/docs/language-reference" )
, ( "Community", ExternalHref "https://unisonweb.org/community" )
, ( "Report a bug", OnClick (ShowModal ReportBugModal) )
, ( "Unison Share", ExternalHref "https://share.unison-lang.org" )
]
unisonSubmenu : Html Msg
unisonSubmenu =
Tooltip.tooltip
(Icon.unisonMark
|> Icon.withClass "sidebar-unison-submenu"
|> Icon.view
)
(Tooltip.textMenu subMenu)
|> Tooltip.withPosition Tooltip.RightOf
|> Tooltip.withArrow Tooltip.End
|> Tooltip.view
viewMainSidebar : Model -> List (Html Msg)
viewMainSidebar model =
[ viewMainSidebarCollapseButton model
, div [ class "expanded-content" ]
[ viewSidebarHeader model.env
, div [ class "sidebar-scroll-area" ]
[ Sidebar.section
"Namespaces and Definitions"
[ Html.map CodebaseTreeMsg (CodebaseTree.view model.codebaseTree) ]
, nav []
(List.map
(\( l, c ) -> Click.view [] [ text l ] c)
subMenu
++ [ a [ class "show-keyboard-shortcuts", onClick (ShowModal HelpModal) ]
[ text "Keyboard Shortcuts"
, KeyboardShortcut.view model.keyboardShortcut (KeyboardShortcut.single QuestionMark)
]
]
)
]
]
, div [ class "collapsed-content" ]
[ unisonSubmenu
, Tooltip.tooltip
(a
[ class "show-help-collapsed", onClick (ShowModal HelpModal) ]
[ KeyboardShortcut.view model.keyboardShortcut (KeyboardShortcut.single QuestionMark)
]
)
(Tooltip.Text "Keyboard Shortcuts")
|> Tooltip.withPosition Tooltip.RightOf
|> Tooltip.withArrow Tooltip.Middle
|> Tooltip.view
]
]
viewHelpModal : OperatingSystem -> KeyboardShortcut.Model -> Html Msg
viewHelpModal os keyboardShortcut =
let
viewRow label instructions =
div
[ class "row" ]
[ label
, div [ class "instructions" ] instructions
]
viewInstructions label shortcuts =
viewRow label [ KeyboardShortcut.viewShortcuts keyboardShortcut shortcuts ]
openFinderInstructions =
case os of
MacOS ->
[ KeyboardShortcut.Chord Meta (K Key.Lower), KeyboardShortcut.Chord Ctrl (K Key.Lower), KeyboardShortcut.single ForwardSlash ]
_ ->
[ KeyboardShortcut.Chord Ctrl (K Key.Lower), KeyboardShortcut.single ForwardSlash ]
toggleSidebarInstructions =
case os of
MacOS ->
[ KeyboardShortcut.Chord Meta (B Key.Lower), KeyboardShortcut.Chord Ctrl (B Key.Lower) ]
_ ->
[ KeyboardShortcut.Chord Ctrl (B Key.Lower), KeyboardShortcut.single (S Key.Lower) ]
content =
Modal.Content
(section
[ class "shortcuts" ]
[ div [ class "shortcut-group" ]
[ h3 [] [ text "General" ]
, viewInstructions (span [] [ text "Keyboard shortcuts", UI.subtle " (this dialog)" ]) [ KeyboardShortcut.single QuestionMark ]
, viewInstructions (text "Open Finder") openFinderInstructions
, viewInstructions (text "Toggle sidebar") toggleSidebarInstructions
, viewInstructions (text "Move focus up") [ KeyboardShortcut.single ArrowUp, KeyboardShortcut.single (K Key.Lower) ]
, viewInstructions (text "Move focus down") [ KeyboardShortcut.single ArrowDown, KeyboardShortcut.single (J Key.Lower) ]
, viewInstructions (text "Close focused definition") [ KeyboardShortcut.single (X Key.Lower) ]
, viewInstructions (text "Expand/Collapse focused definition") [ KeyboardShortcut.single Space ]
]
, div [ class "shortcut-group" ]
[ h3 [] [ text "Finder" ]
, viewInstructions (text "Clear search query") [ KeyboardShortcut.single Escape ]
, viewInstructions (span [] [ text "Close", UI.subtle " (when search query is empty)" ]) [ KeyboardShortcut.single Escape ]
, viewInstructions (text "Move focus up") [ KeyboardShortcut.single ArrowUp ]
, viewInstructions (text "Move focus down") [ KeyboardShortcut.single ArrowDown ]
, viewInstructions (text "Open focused definition") [ KeyboardShortcut.single Enter ]
, viewRow (text "Open definition")
[ KeyboardShortcut.viewBase
[ KeyboardShortcut.viewKey os Semicolon False
, KeyboardShortcut.viewThen
, KeyboardShortcut.viewKeyBase "1-9" False
]
]
]
]
)
in
Modal.modal "help-modal" CloseModal content
|> Modal.withHeader "Keyboard shortcuts"
|> Modal.view
githubLinkButton : String -> Html msg
githubLinkButton repo =
Button.linkIconThenLabel ("https://github.com/" ++ repo) Icon.github repo
|> Button.small
|> Button.contained
|> Button.view
viewPublishModal : Html Msg
viewPublishModal =
let
content =
Modal.Content
(section
[]
[ p [ class "main" ]
[ text "With your Unison codebase on GitHub, open a Pull Request against "
, githubLinkButton "unisonweb/share"
, text " to list (or unlist) your project on Unison Share."
]
, a [ class "help", href "https://www.unisonweb.org/docs/codebase-organization/#day-to-day-development-creating-and-merging-pull-requests", rel "noopener", target "_blank" ] [ text "How do I get my code on GitHub?" ]
]
)
in
Modal.modal "publish-modal" CloseModal content
|> Modal.withHeader "Publish your project on Unison Share"
|> Modal.view
viewReportBugModal : Html Msg
viewReportBugModal =
let
content =
Modal.Content
(div []
[ section []
[ p [] [ text "We try our best, but bugs unfortunately creep through :(" ]
, p [] [ text "We greatly appreciate feedback and bug reports—its very helpful for providing the best developer experience when working with Unison." ]
]
, UI.divider
, section [ class "actions" ]
[ p [] [ text "Visit our GitHub repositories to report bugs and provide feedback" ]
, div [ class "action" ]
[ githubLinkButton "unisonweb/codebase-ui"
, text "for reports on"
, strong [] [ text "Unison Local" ]
, span [ class "subtle" ] [ text "(this UI)" ]
]
, div [ class "action" ]
[ githubLinkButton "unisonweb/unison"
, text "for reports on the"
, strong [] [ text "Unison Language" ]
, span [ class "subtle" ] [ text "(UCM)" ]
]
]
]
)
in
Modal.modal "report-bug-modal" CloseModal content
|> Modal.withHeader "Report a Bug"
|> Modal.view
viewModal :
{ m | env : Env, modal : Modal, keyboardShortcut : KeyboardShortcut.Model }
-> Html Msg
viewModal model =
case model.modal of
NoModal ->
UI.nothing
FinderModal m ->
Html.map FinderMsg (Finder.view m)
HelpModal ->
viewHelpModal model.env.operatingSystem model.keyboardShortcut
PublishModal ->
viewPublishModal
ReportBugModal ->
viewReportBugModal
viewAppLoading : Html msg
viewAppLoading =
div [ id "app" ]
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
, PageLayout.view
(PageLayout.SidebarLayout
{ sidebar = []
, sidebarToggled = False
, content = PageLayout.PageContent []
}
)
]
viewAppError : Http.Error -> Html msg
viewAppError error =
div [ id "app" ]
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
, PageLayout.view
(PageLayout.SidebarLayout
{ sidebar = []
, sidebarToggled = False
, content =
PageLayout.PageContent
[ div [ class "app-error" ]
[ Icon.view Icon.warn
, p [ title (Api.errorToString error) ]
[ text "Unison Local could not be started." ]
]
]
}
)
]
view : Model -> Browser.Document Msg
view model =
let
pageContent =
case model.route of
Route.Perspective _ ->
Html.map PerspectiveLandingMsg
(PerspectiveLanding.view
model.env
model.perspectiveLanding
)
Route.Definition _ _ ->
Html.map WorkspaceMsg (Workspace.view model.workspace)
page =
PageLayout.SidebarLayout
{ sidebar = viewMainSidebar model
, sidebarToggled = model.sidebarToggled
, content = PageLayout.PageContent [ pageContent ]
}
in
{ title = "Unison Local"
, body = [ div [ id "app" ] [ AppHeader.view (viewAppHeader model), PageLayout.view page, viewModal model ] ]
}