1
+ import Button from "@material-ui/core/Button"
1
2
import { makeStyles } from "@material-ui/core/styles"
2
3
import WarningIcon from "@material-ui/icons/ErrorOutlineRounded"
4
+ import RefreshOutlined from "@material-ui/icons/RefreshOutlined"
3
5
import { useMachine } from "@xstate/react"
4
- import { WorkspaceAgent } from "api/typesGenerated"
5
6
import { portForwardURL } from "components/PortForwardButton/PortForwardButton"
6
7
import { Stack } from "components/Stack/Stack"
7
8
import { FC , useCallback , useEffect , useRef , useState } from "react"
@@ -74,7 +75,11 @@ const TerminalPage: FC<
74
75
applicationsHost,
75
76
} = terminalState . context
76
77
const reloading = useReloading ( isDisconnected )
77
- const startupWarning = useStartupWarning ( workspaceAgent )
78
+ const shouldDisplayStartupWarning = workspaceAgent
79
+ ? [ "starting" , "starting_timeout" , "start_error" ] . includes (
80
+ workspaceAgent . lifecycle_state ,
81
+ )
82
+ : false
78
83
79
84
// handleWebLink handles opening of URLs in the terminal!
80
85
const handleWebLink = useCallback (
@@ -284,7 +289,7 @@ const TerminalPage: FC<
284
289
</ Stack >
285
290
) }
286
291
</ div >
287
- { startupWarning . shouldDisplay && (
292
+ { shouldDisplayStartupWarning && (
288
293
< div className = { styles . alert } role = "alert" >
289
294
< WarningIcon className = { styles . alertIcon } />
290
295
< div >
@@ -295,32 +300,24 @@ const TerminalPage: FC<
295
300
You can use it but dotfiles aren‘t setup yet
296
301
</ div >
297
302
</ div >
303
+ < div className = { styles . alertActions } >
304
+ < Button
305
+ startIcon = { < RefreshOutlined /> }
306
+ size = "small"
307
+ onClick = { ( ) => {
308
+ window . location . reload ( )
309
+ } }
310
+ >
311
+ Refresh
312
+ </ Button >
313
+ </ div >
298
314
</ div >
299
315
) }
300
316
< div className = { styles . terminal } ref = { xtermRef } data-testid = "terminal" />
301
317
</ >
302
318
)
303
319
}
304
320
305
- const useStartupWarning = ( agent ?: WorkspaceAgent ) => {
306
- const [ shouldDisplay , setShouldDisplay ] = useState ( false )
307
-
308
- useEffect ( ( ) => {
309
- if ( agent ) {
310
- setShouldDisplay (
311
- [ "starting" , "starting_timeout" , "start_error" ] . includes (
312
- agent . lifecycle_state ,
313
- ) ,
314
- )
315
- }
316
- } , [ agent ] )
317
-
318
- return {
319
- shouldDisplay,
320
- dismiss : ( ) => setShouldDisplay ( false ) ,
321
- }
322
- }
323
-
324
321
const useReloading = ( isDisconnected : boolean ) => {
325
322
const [ status , setStatus ] = useState < "reloading" | "notReloading" > (
326
323
"notReloading" ,
@@ -425,6 +422,9 @@ const useStyles = makeStyles((theme) => ({
425
422
fontSize : 14 ,
426
423
color : theme . palette . text . secondary ,
427
424
} ,
425
+ alertActions : {
426
+ marginLeft : "auto" ,
427
+ } ,
428
428
} ) )
429
429
430
430
export default TerminalPage
0 commit comments