-
Notifications
You must be signed in to change notification settings - Fork 902
feat(site): Show warning if startup script is running #7326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
29301b9
98dca9f
58a8fd6
022796f
80545e4
36d5d7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import Button from "@material-ui/core/Button" | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import WarningIcon from "@material-ui/icons/ErrorOutlineRounded" | ||
import RefreshOutlined from "@material-ui/icons/RefreshOutlined" | ||
import { useMachine } from "@xstate/react" | ||
import { WorkspaceAgent } from "api/typesGenerated" | ||
import { portForwardURL } from "components/PortForwardButton/PortForwardButton" | ||
import { Stack } from "components/Stack/Stack" | ||
import { FC, useCallback, useEffect, useRef, useState } from "react" | ||
|
@@ -74,7 +75,11 @@ const TerminalPage: FC< | |
applicationsHost, | ||
} = terminalState.context | ||
const reloading = useReloading(isDisconnected) | ||
const startupWarning = useStartupWarning(workspaceAgent) | ||
const shouldDisplayStartupWarning = workspaceAgent | ||
? ["starting", "starting_timeout", "start_error"].includes( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh I see. I totally agree. |
||
workspaceAgent.lifecycle_state, | ||
) | ||
: false | ||
|
||
// handleWebLink handles opening of URLs in the terminal! | ||
const handleWebLink = useCallback( | ||
|
@@ -284,7 +289,7 @@ const TerminalPage: FC< | |
</Stack> | ||
)} | ||
</div> | ||
{startupWarning.shouldDisplay && ( | ||
{shouldDisplayStartupWarning && ( | ||
<div className={styles.alert} role="alert"> | ||
<WarningIcon className={styles.alertIcon} /> | ||
<div> | ||
|
@@ -295,32 +300,24 @@ const TerminalPage: FC< | |
You can use it but dotfiles aren‘t setup yet | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
<div className={styles.alertActions}> | ||
<Button | ||
startIcon={<RefreshOutlined />} | ||
size="small" | ||
onClick={() => { | ||
window.location.reload() | ||
}} | ||
> | ||
Refresh | ||
</Button> | ||
</div> | ||
</div> | ||
)} | ||
<div className={styles.terminal} ref={xtermRef} data-testid="terminal" /> | ||
</> | ||
) | ||
} | ||
|
||
const useStartupWarning = (agent?: WorkspaceAgent) => { | ||
const [shouldDisplay, setShouldDisplay] = useState(false) | ||
|
||
useEffect(() => { | ||
if (agent) { | ||
setShouldDisplay( | ||
["starting", "starting_timeout", "start_error"].includes( | ||
agent.lifecycle_state, | ||
), | ||
) | ||
} | ||
}, [agent]) | ||
|
||
return { | ||
shouldDisplay, | ||
dismiss: () => setShouldDisplay(false), | ||
} | ||
} | ||
|
||
const useReloading = (isDisconnected: boolean) => { | ||
const [status, setStatus] = useState<"reloading" | "notReloading">( | ||
"notReloading", | ||
|
@@ -425,6 +422,9 @@ const useStyles = makeStyles((theme) => ({ | |
fontSize: 14, | ||
color: theme.palette.text.secondary, | ||
}, | ||
alertActions: { | ||
marginLeft: "auto", | ||
}, | ||
})) | ||
|
||
export default TerminalPage |
Uh oh!
There was an error while loading. Please reload this page.