- Notifications
You must be signed in to change notification settings - Fork1.1k
fix(UI): workspace restart button stops build before starting a new one#7301
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
4079fc5a6cbf341f1d388e8e88b42e2b89d585ece45041d5eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,6 +30,7 @@ import { UpdateBuildParametersDialog } from "./UpdateBuildParametersDialog" | ||
| import { ChangeVersionDialog } from "./ChangeVersionDialog" | ||
| import { useQuery } from "@tanstack/react-query" | ||
| import { getTemplateVersions } from "api/api" | ||
| import { useRestartWorkspace } from "./hooks" | ||
| interface WorkspaceReadyPageProps { | ||
| workspaceState: StateFrom<typeof workspaceMachine> | ||
| @@ -77,6 +78,12 @@ export const WorkspaceReadyPage = ({ | ||
| enabled: changeVersionDialogOpen, | ||
| }) | ||
| const { | ||
| mutate: restartWorkspace, | ||
| error: restartBuildError, | ||
| isLoading: isRestarting, | ||
| } = useRestartWorkspace() | ||
| // keep banner machine in sync with workspace | ||
| useEffect(() => { | ||
| bannerSend({ type: "REFRESH_WORKSPACE", workspace }) | ||
| @@ -120,9 +127,11 @@ export const WorkspaceReadyPage = ({ | ||
| ), | ||
| }} | ||
| isUpdating={workspaceState.matches("ready.build.requestingUpdate")} | ||
| isRestarting={isRestarting} | ||
Kira-Pilot marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| workspace={workspace} | ||
| handleStart={() => workspaceSend({ type: "START" })} | ||
| handleStop={() => workspaceSend({ type: "STOP" })} | ||
| handleRestart={() => restartWorkspace(workspace)} | ||
| handleDelete={() => workspaceSend({ type: "ASK_DELETE" })} | ||
| handleUpdate={() => workspaceSend({ type: "UPDATE" })} | ||
| handleCancel={() => workspaceSend({ type: "CANCEL" })} | ||
| @@ -140,7 +149,7 @@ export const WorkspaceReadyPage = ({ | ||
| hideVSCodeDesktopButton={featureVisibility["browser_only"]} | ||
| workspaceErrors={{ | ||
| [WorkspaceErrors.GET_BUILDS_ERROR]: getBuildsError, | ||
| [WorkspaceErrors.BUILD_ERROR]: buildError || restartBuildError, | ||
| [WorkspaceErrors.CANCELLATION_ERROR]: cancellationError, | ||
| }} | ||
| buildInfo={buildInfo} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { restartWorkspace } from "api/api" | ||
| import { useMutation } from "@tanstack/react-query" | ||
| export const useRestartWorkspace = () => { | ||
| return useMutation({ | ||
| mutationFn: restartWorkspace, | ||
| }) | ||
Kira-Pilot marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
MemberAuthor 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. Originally, I wanted to use an implementation closer to the following, which react query'sdocs suggest is possible: but Contributor 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. I put a comment above, I think you don't need to have each API call into a "query". You can have a single function to restart the workspace and wrap this function into a query. MemberAuthor 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. Hmmm that's a good idea. Let me try it! MemberAuthor 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. @BrunoQuaresma Woo that's a lot better! Thanks! | ||