8000 feat(site): Display workspace build error + option to retry in debug mode by BrunoQuaresma · Pull Request #6903 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat(site): Display workspace build error + option to retry in debug mode #6903

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

Merged
merged 10 commits into from
Mar 31, 2023
Prev Previous commit
Next Next commit
Simplify quotas
  • Loading branch information
BrunoQuaresma committed Mar 30, 2023
commit 4601bacd6c96093581c6ae34c9addf9ab6e0c27f
8 changes: 2 additions & 6 deletions site/src/pages/WorkspacePage/WorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMachine } from "@xstate/react"
import { AlertBanner } from "components/AlertBanner/AlertBanner"
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
import { Loader } from "components/Loader/Loader"
import { FC, useEffect } from "react"
import { FC } from "react"
import { useParams } from "react-router-dom"
import { quotaMachine } from "xServices/quotas/quotasXService"
import { workspaceMachine } from "xServices/workspace/workspaceXService"
Expand All @@ -27,14 +27,10 @@ export const WorkspacePage: FC = () => {
getTemplateParametersWarning,
checkPermissionsError,
} = workspaceState.context
const [quotaState, quotaSend] = useMachine(quotaMachine)
const [quotaState] = useMachine(quotaMachine, { context: { username } })
const { getQuotaError } = quotaState.context
const styles = useStyles()

useEffect(() => {
username && quotaSend({ type: "GET_QUOTA", username })
}, [username, quotaSend])

return (
<ChooseOne>
<Cond condition={workspaceState.matches("error")}>
Expand Down
18 changes: 4 additions & 14 deletions site/src/xServices/quotas/quotasXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,27 @@ import * as API from "../../api/api"
import { WorkspaceQuota } from "../../api/typesGenerated"

export type QuotaContext = {
username: string
quota?: WorkspaceQuota
getQuotaError?: Error | unknown
}

export type QuotaEvent = {
type: "GET_QUOTA"
username: string
}

export const quotaMachine = createMachine(
{
id: "quotasMachine",
predictableActionArguments: true,
tsTypes: {} as import("./quotasXService.typegen").Typegen0,
schema: {
context: {} as QuotaContext,
events: {} as QuotaEvent,
services: {
getQuota: {
data: {} as WorkspaceQuota,
},
},
},
context: {},
initial: "idle",
initial: "gettingQuotas",
states: {
idle: {
on: {
GET_QUOTA: "gettingQuotas",
},
},
idle: {},
gettingQuotas: {
entry: "clearGetQuotaError",
invoke: {
Expand Down Expand Up @@ -67,7 +57,7 @@ export const quotaMachine = createMachine(
}),
},
services: {
getQuota: (context, event) => API.getWorkspaceQuota(event.username),
getQuota: ({ username }) => API.getWorkspaceQuota(username),
},
},
)
0