Skip to content

Commit f2efc82

Browse files
authored
Merge pull request #29 from unisonweb/improve-noconnection-states
Improve startup connection error
2 parents 8479551 + 402fed1 commit f2efc82

File tree

6 files changed

+79
-8
lines changed

6 files changed

+79
-8
lines changed

elm-git.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"git-dependencies": {
33
"direct": {
4-
"https://github.com/unisonweb/ui-core": "913ad29285b9656dd43c05708d79dd826684e85a"
4+
"https://github.com/unisonweb/ui-core": "9cb49aa3c4180730d27e94586fc641bbcb8aa5e5"
55
},
66
"indirect": {}
77
}

src/Ucm/App.elm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Lib.Util as Util
88
import UI.Button as Button
99
import UI.Icon as Icon
1010
import UI.StatusBanner as StatusBanner
11+
import UI.StatusIndicator as StatusIndicator
1112
import Ucm.Api as Api
1213
import Ucm.AppContext exposing (AppContext)
1314
import Ucm.UcmConnectivity exposing (UcmConnectivity(..))
@@ -265,15 +266,15 @@ view model =
265266
{ title = "UCM Desktop | Couldn't connect to the UCM CLI"
266267
, body =
267268
[ div []
268-
[ div [ class "app-error" ]
269-
[ h2 [] [ text "Couldn't connect to the UCM CLI" ]
269+
[ div [ class "app-message" ]
270+
[ h2 [] [ StatusIndicator.view StatusIndicator.working, text "Waiting on the UCM CLI" ]
270271
, p []
271272
[ text "Please make sure UCM is running on the right port like so: "
272273
, br [] []
273274
, code [] [ text apiUrl ]
274275
]
275-
, Button.iconThenLabel ReCheckUCMConnectivity Icon.refresh "Try again"
276-
|> Button.emphasized
276+
, Button.iconThenLabel ReCheckUCMConnectivity Icon.plug "Connect to the UCM CLI"
277+
|> Button.large
277278
|> Button.view
278279
]
279280
]

src/Ucm/Workspace/WorkspacePane.elm

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type Msg
6969
= NoOp
7070
| Focus
7171
| FetchDefinitionItemFinished Reference (HttpResult DefinitionItem)
72+
| Refetch WorkspaceItemRef
7273
| CloseWorkspaceItem WorkspaceItemRef
7374
| ChangeDefinitionItemTab WorkspaceItemRef WorkspaceItem.DefinitionItemTab
7475
| OpenDependency Reference
@@ -89,6 +90,24 @@ update config msg model =
8990
Focus ->
9091
( model, Cmd.none, RequestFocus )
9192

93+
Refetch ref ->
94+
let
95+
( model_, cmd ) =
96+
case ref of
97+
SearchResultsItemRef _ ->
98+
( model, Cmd.none )
99+
100+
DefinitionItemRef dRef ->
101+
let
102+
nextWorkspaceItems =
103+
WorkspaceItems.replace model.workspaceItems ref (WorkspaceItem.Loading ref)
104+
in
105+
( { model | workspaceItems = nextWorkspaceItems }
106+
, HttpApi.perform config.api (fetchDefinition config dRef)
107+
)
108+
in
109+
( model_, cmd, NoOut )
110+
92111
FetchDefinitionItemFinished dRef (Ok defItem) ->
93112
let
94113
workspaceItemRef =
@@ -588,10 +607,20 @@ viewItem definitionSummaryTooltip item isFocused =
588607
WorkspaceItem.Failure wsRef e ->
589608
cardBase
590609
|> WorkspaceCard.withTitle ("Failed to load definition: " ++ WorkspaceItemRef.toHumanString wsRef)
610+
|> WorkspaceCard.withTitlebarRight
611+
[ Button.icon (CloseWorkspaceItem wsRef) Icon.x
612+
|> Button.subdued
613+
|> Button.small
614+
|> Button.view
615+
]
591616
|> WorkspaceCard.withContent
592-
[ span [ class "error" ]
593-
[ span [ class "error_icon" ] [ Icon.view Icon.warn ]
594-
, text (Util.httpErrorToString e)
617+
[ div [ class "workspace-card_error" ]
618+
[ span [ class "error" ]
619+
[ span [ class "error_icon" ] [ Icon.view Icon.warn ]
620+
, text (Util.httpErrorToString e)
621+
]
622+
, Button.iconThenLabel (Refetch wsRef) Icon.refresh "Try again"
623+
|> Button.view
595624
]
596625
]
597626
in

src/css/app-message.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.app-message {
2+
margin: 6rem auto;
3+
width: 40rem;
4+
display: flex;
5+
flex-direction: column;
6+
justify-content: center;
7+
align-items: center;
8+
flex-shrink: 0;
9+
gap: 1rem;
10+
text-align: center;
11+
color: var(--u-color_info_text-on-element_subdued);
12+
font-size: 1.25rem;
13+
border-radius: var(--border-radius-base);
14+
padding: 2rem;
15+
}
16+
17+
.app-message h2 {
18+
color: var(--u-color_critical_text-on-element);
19+
font-size: 2rem;
20+
display: flex;
21+
flex-direction: row;
22+
gap: 0.5rem;
23+
align-items: center;
24+
}
25+
26+
.app-message p {
27+
margin-bottom: 0;
28+
}
29+
30+
.app-message code {
31+
margin-top: 0.25rem;
32+
color: var(--u-color_text_subdued);
33+
font-weight: bold;
34+
}

src/css/ucm/workspace/workspace-card.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
width: 100%;
6565
}
6666

67+
& .workspace-card_error {
68+
display: flex;
69+
flex-direction: column;
70+
gap: 0.5rem;
71+
}
72+
6773
& .workspace-card_loading {
6874
display: flex;
6975
flex-direction: column;

src/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "./css/unison-dark.css";
22
@import "./css/unison-light.css";
33
@import "./css/app-error.css";
4+
@import "./css/app-message.css";
45
@import "./css/window.css";
56
@import "./css/ucm/search-project-sheet.css";
67
@import "./css/ucm/search-branch-sheet.css";

0 commit comments

Comments
 (0)