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

Commit 53ef0dd

Browse files
authored
Merge pull request #280 from unisonweb/appcontext-cleanup
Clean AppContext and rename Ucm to Unison Local
2 parents 105a4b9 + 8188dd8 commit 53ef0dd

File tree

13 files changed

+85
-83
lines changed

13 files changed

+85
-83
lines changed

src/App.elm

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import Browser
55
import Browser.Navigation as Nav
66
import CodebaseTree
77
import Definition.Reference exposing (Reference)
8-
import Env exposing (AppContext(..), Env, OperatingSystem(..))
8+
import Env exposing (Env, OperatingSystem(..))
9+
import Env.AppContext as AppContext exposing (AppContext(..))
910
import Finder
1011
import Finder.SearchOptions as SearchOptions
1112
import FullyQualifiedName as FQN exposing (FQN)
@@ -451,10 +452,10 @@ appTitle clickMsg appContext =
451452

452453
content =
453454
case appContext of
454-
Env.Ucm ->
455-
h1 [] [ text "Unison", span [ class "context ucm" ] [ text "Local" ] ]
455+
UnisonLocal ->
456+
h1 [] [ text "Unison", span [ class "context unison-local" ] [ text "Local" ] ]
456457

457-
Env.UnisonShare ->
458+
UnisonShare ->
458459
h1 [] [ text "Unison", span [ class "context unison-share" ] [ text "Share" ] ]
459460
in
460461
appTitle_ content
@@ -479,7 +480,7 @@ viewAppHeader model =
479480

480481
banner =
481482
case appContext of
482-
Ucm ->
483+
UnisonLocal ->
483484
Nothing
484485

485486
UnisonShare ->
@@ -544,7 +545,7 @@ subMenu appContext =
544545
, ( "Community", ExternalHref "https://unisonweb.org/community" )
545546
, ( "Report a bug", OnClick (ShowModal ReportBugModal) )
546547
]
547-
++ (if Env.isUnisonLocal appContext then
548+
++ (if AppContext.isUnisonLocal appContext then
548549
[ ( "Unison Share", ExternalHref "https://share.unison-lang.org" ) ]
549550

550551
else
@@ -578,7 +579,7 @@ viewMainSidebar model =
578579
Perspective.toNamespacePerspective perspective >> ChangePerspective
579580

580581
sidebarContent =
581-
if Perspective.isCodebasePerspective perspective && Env.isUnisonShare appContext then
582+
if Perspective.isCodebasePerspective perspective && AppContext.isUnisonShare appContext then
582583
UnisonShare.SidebarContent.view changePerspectiveMsg
583584

584585
else
@@ -732,7 +733,7 @@ viewReportBugModal appContext =
732733
, div [ class "action" ]
733734
[ githubLinkButton "unisonweb/codebase-ui"
734735
, text "for reports on"
735-
, strong [] [ text (Env.appContextToString appContext) ]
736+
, strong [] [ text (AppContext.toString appContext) ]
736737
, span [ class "subtle" ] [ text "(this UI)" ]
737738
]
738739
, div [ class "action" ]
@@ -784,7 +785,7 @@ viewAppError : AppContext -> Http.Error -> Html msg
784785
viewAppError appContext error =
785786
let
786787
context =
787-
Env.appContextToString appContext
788+
AppContext.toString appContext
788789
in
789790
div [ id "app" ]
790791
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing appContext))
@@ -801,12 +802,7 @@ view : Model -> Browser.Document Msg
801802
view model =
802803
let
803804
title_ =
804-
case model.env.appContext of
805-
UnisonShare ->
806-
"Unison Share"
807-
808-
Ucm ->
809-
"Unison Local"
805+
AppContext.toString model.env.appContext
810806

811807
page =
812808
case model.route of

src/Env.elm

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
module Env exposing (..)
22

33
import Api exposing (ApiBasePath(..))
4+
import Env.AppContext as AppContext exposing (AppContext)
45
import Perspective exposing (Perspective)
56

67

7-
type AppContext
8-
= UnisonShare
9-
| Ucm
10-
11-
128
type OperatingSystem
139
= MacOS
1410
| Windows
@@ -40,50 +36,11 @@ init flags perspective =
4036
{ operatingSystem = operatingSystemFromString flags.operatingSystem
4137
, basePath = flags.basePath
4238
, apiBasePath = ApiBasePath flags.apiBasePath
43-
, appContext = appContextFromString flags.appContext
39+
, appContext = AppContext.fromString flags.appContext
4440
, perspective = perspective
4541
}
4642

4743

48-
appContextFromString : String -> AppContext
49-
appContextFromString rawContext =
50-
if rawContext == "UnisonShare" then
51-
UnisonShare
52-
53-
else
54-
Ucm
55-
56-
57-
appContextToString : AppContext -> String
58-
appContextToString appContext =
59-
case appContext of
60-
UnisonShare ->
61-
"Unison Share"
62-
63-
Ucm ->
64-
"Unison Local"
65-
66-
67-
isUnisonShare : AppContext -> Bool
68-
isUnisonShare appContext =
69-
case appContext of
70-
UnisonShare ->
71-
True
72-
73-
Ucm ->
74-
False
75-
76-
77-
isUnisonLocal : AppContext -> Bool
78-
isUnisonLocal appContext =
79-
case appContext of
80-
UnisonShare ->
81-
False
82-
83-
Ucm ->
84-
True
85-
86-
8744
operatingSystemFromString : String -> OperatingSystem
8845
operatingSystemFromString rawOs =
8946
case rawOs of

src/Env/AppContext.elm

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module Env.AppContext exposing (..)
2+
3+
4+
type AppContext
5+
= UnisonShare
6+
| UnisonLocal
7+
8+
9+
fromString : String -> AppContext
10+
fromString rawContext =
11+
if rawContext == "UnisonShare" then
12+
UnisonShare
13+
14+
else
15+
UnisonLocal
16+
17+
18+
toString : AppContext -> String
19+
toString appContext =
20+
case appContext of
21+
UnisonShare ->
22+
"Unison Share"
23+
24+
UnisonLocal ->
25+
"Unison Local"
26+
27+
28+
isUnisonShare : AppContext -> Bool
29+
isUnisonShare appContext =
30+
case appContext of
31+
UnisonShare ->
32+
True
33+
34+
UnisonLocal ->
35+
False
36+
37+
38+
isUnisonLocal : AppContext -> Bool
39+
isUnisonLocal appContext =
40+
case appContext of
41+
UnisonShare ->
42+
False
43+
44+
UnisonLocal ->
45+
True

src/PerspectiveLanding.elm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Definition.Doc as Doc
55
import Definition.Readme as Readme
66
import Definition.Reference exposing (Reference)
77
import Env exposing (Env)
8+
import Env.AppContext exposing (AppContext(..))
89
import FullyQualifiedName as FQN exposing (FQN)
910
import Html exposing (Html, a, article, div, h2, header, p, section, span, strong, text)
1011
import Html.Attributes exposing (class, href, id, rel, target)
@@ -109,7 +110,7 @@ viewEmptyState title description cta =
109110
]
110111

111112

112-
viewEmptyStateCodebase : Env.AppContext -> Html Msg
113+
viewEmptyStateCodebase : AppContext -> Html Msg
113114
viewEmptyStateCodebase appContext =
114115
let
115116
button =
@@ -118,9 +119,9 @@ viewEmptyStateCodebase appContext =
118119
|> Button.medium
119120
in
120121
case appContext of
121-
Env.Ucm ->
122+
UnisonLocal ->
122123
viewEmptyState
123-
(span [ class "ucm" ] [ text "Your ", span [ class "context" ] [ text "Local" ], text " Unison Codebase" ])
124+
(span [ class "unison-local" ] [ text "Your ", span [ class "context" ] [ text "Local" ], text " Unison Codebase" ])
124125
[ p [] [ text "Browse, search, read docs, open definitions, and explore your local codebase." ]
125126
, p []
126127
[ text "Check out "
@@ -130,7 +131,7 @@ viewEmptyStateCodebase appContext =
130131
]
131132
button
132133

133-
Env.UnisonShare ->
134+
UnisonShare ->
134135
viewEmptyState
135136
(span [ class "unison-share" ] [ text "Unison ", span [ class "context" ] [ text "Share" ] ])
136137
[ p [] [ text "Explore to discover and share Unison libraries, documentation, types, and terms." ] ]

src/PreApp.elm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import App
55
import Browser
66
import Browser.Navigation as Nav
77
import Env exposing (Flags)
8+
import Env.AppContext as AppContext
89
import Html
910
import Http
1011
import Perspective exposing (Perspective, PerspectiveParams)
@@ -121,7 +122,7 @@ view : Model -> Browser.Document Msg
121122
view model =
122123
let
123124
appContext flags =
124-
Env.appContextFromString flags.appContext
125+
AppContext.fromString flags.appContext
125126
in
126127
case model of
127128
Initializing preEnv ->

src/Ucm.elm renamed to src/UnisonLocal.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Ucm exposing (..)
1+
module UnisonLocal exposing (..)
22

33
import App
44
import Browser

src/css/composites/app-header.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
color: var(--color-app-header-context-unison-share-fg);
5252
}
5353

54-
#app-header .app-title .ucm {
55-
color: var(--color-app-header-context-ucm-fg);
54+
#app-header .app-title .unison-local {
55+
color: var(--color-app-header-context-unison-local-fg);
5656
}
5757

5858
#app-header .right {

src/css/perspective-landing.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
width: 28rem;
102102
}
103103

104-
.perspective-landing-empty-state .ucm .context {
104+
.perspective-landing-empty-state .unison-local .context {
105105
color: var(--color-pink-2);
106106
}
107107

src/css/themes/unison/light.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
--color-app-header-subtle-fg: var(--color-gray-lighten-20);
2323
--color-app-header-subtle-fg-em: var(--color-gray-lighten-50);
2424
--color-app-header-context-unison-share-fg: var(--color-purple-4);
25-
--color-app-header-context-ucm-fg: var(--color-pink-3);
25+
--color-app-header-context-unison-local-fg: var(--color-pink-3);
2626
--color-app-header-border: var(--color-gray-base);
2727

2828
--color-keyboard-shortcut-key-fg: var(--color-gray-base);
File renamed without changes.

src/ucm.js renamed to src/unisonLocal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "./init";
22
import detectOs from "./detectOs";
33
import preventDefaultGlobalKeyboardEvents from "./preventDefaultGlobalKeyboardEvents";
4-
import { Elm } from "./Ucm.elm";
4+
import { Elm } from "./UnisonLocal.elm";
55

66
const basePath = new URL(document.baseURI).pathname;
77

@@ -20,10 +20,10 @@ const flags = {
2020
operatingSystem: detectOs(window.navigator),
2121
basePath,
2222
apiBasePath,
23-
appContext: "Ucm",
23+
appContext: "UnisonLocal",
2424
};
2525

2626
preventDefaultGlobalKeyboardEvents();
2727

28-
// The main entry point for the `ucm` target of the Codebase UI.
29-
Elm.Ucm.init({ flags });
28+
// The main entry point for the `UnisonLocal` target of the Codebase UI.
29+
Elm.UnisonLocal.init({ flags });

webpack.dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
44
const API_URL = process.env.API_URL || "127.0.0.1:8080";
55

66
module.exports = {
7-
entry: "./src/ucm.js",
7+
entry: "./src/unisonLocal.js",
88

99
module: {
1010
rules: [
@@ -42,7 +42,7 @@ module.exports = {
4242
plugins: [
4343
new HtmlWebpackPlugin({
4444
favicon: "./static/favicon.ico",
45-
template: "./src/ucm.ejs",
45+
template: "./src/unisonLocal.ejs",
4646
inject: "body",
4747
publicPath: "/",
4848
base: "/",

webpack.prod.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,35 +80,37 @@ const unisonShareCfg = {
8080
},
8181
};
8282

83-
const ucmCfg = {
83+
const unisonLocalCfg = {
8484
...shared,
8585

86-
entry: "./src/ucm.js",
86+
entry: "./src/unisonLocal.js",
8787

8888
plugins: [
8989
new HtmlWebpackPlugin({
9090
favicon: "./static/favicon.ico",
91-
template: "./src/ucm.ejs",
91+
template: "./src/unisonLocal.ejs",
9292
inject: "body",
9393
publicPath: "/static/",
9494
base: false, // set dynamically by grabbing the 2 first path segments in the url.
95-
filename: path.resolve(__dirname, "dist/ucm/index.html"),
95+
filename: path.resolve(__dirname, "dist/unisonLocal/index.html"),
9696
}),
9797

9898
new FileManagerPlugin({
9999
events: {
100100
onEnd: {
101-
archive: [{ source: "dist/ucm", destination: "dist/ucm.zip" }],
101+
archive: [
102+
{ source: "dist/unisonLocal", destination: "dist/unisonLocal.zip" },
103+
],
102104
},
103105
},
104106
}),
105107
],
106108

107109
output: {
108110
filename: "[name].[contenthash].js",
109-
path: path.resolve(__dirname, "dist/ucm/static"),
111+
path: path.resolve(__dirname, "dist/unisonLocal/static"),
110112
clean: true,
111113
},
112114
};
113115

114-
module.exports = [unisonShareCfg, ucmCfg];
116+
module.exports = [unisonShareCfg, unisonLocalCfg];

0 commit comments

Comments
 (0)