1
1
import Paper from "@material-ui/core/Paper"
2
2
import { makeStyles } from "@material-ui/core/styles"
3
3
import Typography from "@material-ui/core/Typography"
4
+ import OpenInNewIcon from "@material-ui/icons/OpenInNew"
4
5
import React from "react"
5
6
6
7
import * as API from "../../api"
@@ -10,21 +11,20 @@ export interface WorkspaceProps {
10
11
}
11
12
12
13
const useStatusStyles = makeStyles ( ( theme ) => {
13
-
14
14
const common = {
15
15
width : theme . spacing ( 1 ) ,
16
16
height : theme . spacing ( 1 ) ,
17
17
borderRadius : "100%" ,
18
18
backgroundColor : theme . palette . action . disabled ,
19
19
transition : "background-color 200ms ease" ,
20
- } ;
20
+ }
21
21
22
22
return {
23
23
inactive : common ,
24
24
active : {
25
25
...common ,
26
26
backgroundColor : theme . palette . primary . main ,
27
- }
27
+ } ,
28
28
}
29
29
} )
30
30
@@ -35,14 +35,15 @@ const useStatusStyles = makeStyles((theme) => {
35
35
export const StatusIndicator : React . FC < { status : ResourceStatus } > = ( { status } ) => {
36
36
const styles = useStatusStyles ( )
37
37
38
- const className = status === "active" ? styles . active : styles . inactive
39
- return (
40
- < div className = { className } />
41
- )
38
+ if ( status == "loading" ) {
39
+ return < CircularProgress width = { "16px" } />
40
+ } else {
41
+ const className = status === "active" ? styles . active : styles . inactive
42
+ return < div className = { className } />
43
+ }
42
44
}
43
45
44
-
45
- type ResourceStatus = "active" | "inactive"
46
+ type ResourceStatus = "active" | "inactive" | "loading"
46
47
47
48
export interface ResourceRowProps {
48
49
name : string
@@ -53,20 +54,31 @@ export interface ResourceRowProps {
53
54
54
55
const ResourceIconSize = 20
55
56
56
- export const ResourceRow : React . FC < ResourceRowProps > = ( { icon, /* href,*/ name, status } ) => {
57
+ export const ResourceRow : React . FC < ResourceRowProps > = ( { icon, href, name, status } ) => {
57
58
const styles = useResourceRowStyles ( )
58
59
59
- return < div className = { styles . root } >
60
- < div className = { styles . iconContainer } >
61
- < img src = { icon } height = { ResourceIconSize } width = { ResourceIconSize } />
62
- </ div >
63
- < div className = { styles . nameContainer } >
64
- { name }
65
- </ div >
66
- < div className = { styles . statusContainer } >
67
- < StatusIndicator status = { status } />
60
+ return (
61
+ < div className = { styles . root } >
62
+ < div className = { styles . iconContainer } >
63
+ < img src = { icon } height = { ResourceIconSize } width = { ResourceIconSize } />
64
+ </ div >
65
+ < div className = { styles . nameContainer } >
66
+ < Link
67
+ color = { status === "active" ? "primary" : "initial" }
68
+ href = { href }
69
+ rel = "noreferrer noopener"
70
+ target = "_blank"
71
+ underline = "none"
72
+ >
73
+ < span > { name } </ span >
74
+ < OpenInNewIcon fontSize = "inherit" style = { { marginTop : "0.25em" , marginLeft : "0.5em" } } />
75
+ </ Link >
76
+ </ div >
77
+ < div className = { styles . statusContainer } >
78
+ < StatusIndicator status = { status } />
79
+ </ div >
68
80
</ div >
69
- </ div >
81
+ )
70
82
}
71
83
72
84
const useResourceRowStyles = makeStyles ( ( theme ) => ( {
@@ -97,24 +109,22 @@ const useResourceRowStyles = makeStyles((theme) => ({
97
109
display : "flex" ,
98
110
justifyContent : "center" ,
99
111
alignItems : "center" ,
100
- }
112
+ } ,
101
113
} ) )
102
114
103
115
export const Title : React . FC = ( { children } ) => {
104
- const styles = useTitleStyles ( ) ;
116
+ const styles = useTitleStyles ( )
105
117
106
- return < div className = { styles . header } >
107
- < Typography variant = "h6" > { children } </ Typography >
108
- </ div >
118
+ return < div className = { styles . header } > { children } </ div >
109
119
}
110
120
111
121
const useTitleStyles = makeStyles ( ( theme ) => ( {
112
122
header : {
113
123
alignItems : "center" ,
114
124
borderBottom : `1px solid ${ theme . palette . divider } ` ,
115
125
display : "flex" ,
126
+ flexDirection : "row" ,
116
127
height : theme . spacing ( 6 ) ,
117
- justifyContent : "space-between" ,
118
128
marginBottom : theme . spacing ( 2 ) ,
119
129
marginTop : - theme . spacing ( 1 ) ,
120
130
paddingBottom : theme . spacing ( 1 ) ,
@@ -124,76 +134,92 @@ const useTitleStyles = makeStyles((theme) => ({
124
134
} ) )
125
135
126
136
import Timeline from "@material-ui/lab/Timeline"
127
- import TimelineItem from ' @material-ui/lab/TimelineItem' ;
128
- import TimelineSeparator from ' @material-ui/lab/TimelineSeparator' ;
129
- import TimelineConnector from ' @material-ui/lab/TimelineConnector' ;
130
- import TimelineContent from ' @material-ui/lab/TimelineContent' ;
131
- import TimelineDot from ' @material-ui/lab/TimelineDot' ;
137
+ import TimelineItem from " @material-ui/lab/TimelineItem"
138
+ import TimelineSeparator from " @material-ui/lab/TimelineSeparator"
139
+ import TimelineConnector from " @material-ui/lab/TimelineConnector"
140
+ import TimelineContent from " @material-ui/lab/TimelineContent"
141
+ import TimelineDot from " @material-ui/lab/TimelineDot"
132
142
import { QuestionHelp } from "../QuestionHelp"
143
+ import { CircularProgress , Link } from "@material-ui/core"
133
144
134
145
export const WorkspaceTimeline : React . FC = ( ) => {
135
- return < Timeline >
136
- < TimelineItem >
137
- < TimelineSeparator >
138
- < TimelineDot />
139
- < TimelineConnector />
140
- </ TimelineSeparator >
141
- < TimelineContent > Eat</ TimelineContent >
142
- </ TimelineItem >
143
- < TimelineItem >
144
- < TimelineSeparator >
145
- < TimelineDot />
146
- < TimelineConnector />
147
- </ TimelineSeparator >
148
- < TimelineContent > Code</ TimelineContent >
149
- </ TimelineItem >
150
- < TimelineItem >
151
- < TimelineSeparator >
152
- < TimelineDot />
153
- </ TimelineSeparator >
154
- < TimelineContent > Sleep</ TimelineContent >
155
- </ TimelineItem >
156
- </ Timeline >
146
+ return (
147
+ < Timeline >
148
+ < TimelineItem >
149
+ < TimelineSeparator >
150
+ < TimelineDot />
151
+ < TimelineConnector />
152
+ </ TimelineSeparator >
153
+ < TimelineContent > Eat</ TimelineContent >
154
+ </ TimelineItem >
155
+ < TimelineItem >
156
+ < TimelineSeparator >
157
+ < TimelineDot />
158
+ < TimelineConnector />
159
+ </ TimelineSeparator >
160
+ < TimelineContent > Code</ TimelineContent >
161
+ </ TimelineItem >
162
+ < TimelineItem >
163
+ < TimelineSeparator >
164
+ < TimelineDot />
165
+ </ TimelineSeparator >
166
+ < TimelineContent > Sleep</ TimelineContent >
167
+ </ TimelineItem >
168
+ </ Timeline >
169
+ )
157
170
}
158
171
159
172
export const Workspace : React . FC < WorkspaceProps > = ( { workspace } ) => {
160
173
const styles = useStyles ( )
161
174
162
- return < div className = { styles . root } >
163
- < Paper elevation = { 0 } className = { styles . section } >
164
- < Typography variant = "h4" > { workspace . name } </ Typography >
165
- < Typography variant = "body2" color = "textSecondary" >
166
- { "TODO: Project" }
167
- </ Typography >
168
- </ Paper >
169
- < div className = { styles . horizontal } >
170
- < div className = { styles . sideBar } >
171
- < Paper elevation = { 0 } className = { styles . section } >
172
- < Title > < span > Applications</ span > < QuestionHelp /> </ Title >
173
-
174
- < div className = { styles . vertical } >
175
- < ResourceRow name = { "Code Web" } icon = { "/static/vscode.svg" } status = { "active" } />
176
- < ResourceRow name = { "Terminal" } icon = { "/static/terminal.svg" } status = { "active" } />
177
- < ResourceRow name = { "React App" } icon = { "/static/react-icon.svg" } status = { "active" } />
178
-
179
- </ div >
180
- </ Paper >
181
- < Paper elevation = { 0 } className = { styles . section } >
182
- < Title > Resources</ Title >
183
-
184
- < div className = { styles . vertical } >
185
- < ResourceRow name = { "GCS Bucket" } icon = { "/static/google-storage-logo.svg" } status = { "active" } />
186
- < ResourceRow name = { "Windows (x64 - VM)" } icon = { "/static/windows-logo.svg" } status = { "active" } />
187
- < ResourceRow name = { "OSX (M1 - Physical)" } icon = { "/static/apple-logo.svg" } status = { "active" } />
188
- </ div >
175
+ return (
176
+ < div className = { styles . root } >
177
+ < Paper elevation = { 0 } className = { styles . section } >
178
+ < Typography variant = "h4" > { workspace . name } </ Typography >
179
+ < Typography variant = "body2" color = "textSecondary" >
180
+ { "TODO: Project" }
181
+ </ Typography >
182
+ </ Paper >
183
+ < div className = { styles . horizontal } >
184
+ < div className = { styles . sideBar } >
185
+ < Paper elevation = { 0 } className = { styles . section } >
186
+ < Title >
187
+ < Typography variant = "h6" > Applications</ Typography >
188
+ < div style = { { margin : "0em 1em" } } >
189
+ < QuestionHelp />
190
+ </ div >
191
+ </ Title >
192
+
193
+ < div className = { styles . vertical } >
194
+ < ResourceRow name = { "Code Web" } icon = { "/static/vscode.svg" } status = { "active" } />
195
+ < ResourceRow name = { "Terminal" } icon = { "/static/terminal.svg" } status = { "active" } />
196
+ < ResourceRow name = { "React App" } icon = { "/static/react-icon.svg" } status = { "loading" } />
197
+ </ div >
198
+ </ Paper >
199
+ < Paper elevation = { 0 } className = { styles . section } >
200
+ < Title >
201
+ < Typography variant = "h6" > Resources</ Typography >
202
+ < div style = { { margin : "0em 1em" } } >
203
+ < QuestionHelp />
204
+ </ div >
205
+ </ Title >
206
+
207
+ < div className = { styles . vertical } >
208
+ < ResourceRow name = { "GCS Bucket" } icon = { "/static/google-storage-logo.svg" } status = { "active" } />
209
+ < ResourceRow name = { "Windows (x64 - VM)" } icon = { "/static/windows-logo.svg" } status = { "active" } />
210
+ < ResourceRow name = { "OSX (M1 - Physical)" } icon = { "/static/apple-logo.svg" } status = { "inactive" } />
211
+ </ div >
212
+ </ Paper >
213
+ </ div >
214
+ < Paper elevation = { 0 } className = { styles . main } >
215
+ < Title >
216
+ < Typography variant = "h6" > Timeline</ Typography >
217
+ </ Title >
218
+ < WorkspaceTimeline />
189
219
</ Paper >
190
220
</ div >
191
- < Paper elevation = { 0 } className = { styles . main } >
192
- < Title > Timeline</ Title >
193
- < WorkspaceTimeline />
194
- </ Paper >
195
221
</ div >
196
- </ div >
222
+ )
197
223
}
198
224
199
225
namespace Constants {
@@ -202,36 +228,35 @@ namespace Constants {
202
228
}
203
229
204
230
export const useStyles = makeStyles ( ( theme ) => {
205
-
206
231
const common = {
207
232
border : `1px solid ${ theme . palette . divider } ` ,
208
233
borderRadius : Constants . CardRadius ,
209
234
margin : theme . spacing ( 1 ) ,
210
- padding : Constants . CardPadding
235
+ padding : Constants . CardPadding ,
211
236
}
212
237
213
238
return {
214
239
root : {
215
240
display : "flex" ,
216
- flexDirection : "column"
241
+ flexDirection : "column" ,
217
242
} ,
218
243
horizontal : {
219
244
display : "flex" ,
220
- flexDirection : "row"
245
+ flexDirection : "row" ,
221
246
} ,
222
247
vertical : {
223
248
display : "flex" ,
224
- flexDirection : "column"
249
+ flexDirection : "column" ,
225
250
} ,
226
251
section : common ,
227
252
sideBar : {
228
253
display : "flex" ,
229
254
flexDirection : "column" ,
230
- width : "400px"
255
+ width : "400px" ,
231
256
} ,
232
257
main : {
233
258
...common ,
234
- flex : 1
235
- }
259
+ flex : 1 ,
260
+ } ,
236
261
}
237
- } )
262
+ } )
0 commit comments