Skip to content

Commit 98dca9f

Browse files
committed
feat(site): Display a warning message during startup script execution
1 parent 29301b9 commit 98dca9f

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

site/src/api/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ export const getWorkspaceBuildParameters = async (
966966
return response.data
967967
}
968968
type Claims = {
969-
license_expires?: jwt.NumericDate
969+
license_expires?: number
970970
account_type?: string
971971
account_id?: string
972972
trial: boolean

site/src/pages/TerminalPage/TerminalPage.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import Button from "@material-ui/core/Button"
12
import { makeStyles } from "@material-ui/core/styles"
23
import WarningIcon from "@material-ui/icons/ErrorOutlineRounded"
4+
import RefreshOutlined from "@material-ui/icons/RefreshOutlined"
35
import { useMachine } from "@xstate/react"
4-
import { WorkspaceAgent } from "api/typesGenerated"
56
import { portForwardURL } from "components/PortForwardButton/PortForwardButton"
67
import { Stack } from "components/Stack/Stack"
78
import { FC, useCallback, useEffect, useRef, useState } from "react"
@@ -74,7 +75,11 @@ const TerminalPage: FC<
7475
applicationsHost,
7576
} = terminalState.context
7677
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
7883

7984
// handleWebLink handles opening of URLs in the terminal!
8085
const handleWebLink = useCallback(
@@ -284,7 +289,7 @@ const TerminalPage: FC<
284289
</Stack>
285290
)}
286291
</div>
287-
{startupWarning.shouldDisplay && (
292+
{shouldDisplayStartupWarning && (
288293
<div className={styles.alert} role="alert">
289294
<WarningIcon className={styles.alertIcon} />
290295
<div>
@@ -295,32 +300,24 @@ const TerminalPage: FC<
295300
You can use it but dotfiles aren&lsquo;t setup yet
296301
</div>
297302
</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>
298314
</div>
299315
)}
300316
<div className={styles.terminal} ref={xtermRef} data-testid="terminal" />
301317
</>
302318
)
303319
}
304320

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-
324321
const useReloading = (isDisconnected: boolean) => {
325322
const [status, setStatus] = useState<"reloading" | "notReloading">(
326323
"notReloading",
@@ -425,6 +422,9 @@ const useStyles = makeStyles((theme) => ({
425422
fontSize: 14,
426423
color: theme.palette.text.secondary,
427424
},
425+
alertActions: {
426+
marginLeft: "auto",
427+
},
428428
}))
429429

430430
export default TerminalPage

0 commit comments

Comments
 (0)