Skip to content

fix: handle create workspace errors #3346

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 6 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix story with form error
  • Loading branch information
AbhineetJain committed Aug 1, 2022
commit ce2b2f3210575502608279d747dc8cc77c45b59d
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ CreateWorkspaceError.args = {
],
}),
},
initialTouched: {
name: true,
},
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeStyles } from "@material-ui/core/styles"
import TextField from "@material-ui/core/TextField"
import { ErrorSummary } from "components/ErrorSummary/ErrorSummary"
import { FormikContextType, useFormik } from "formik"
import { FormikContextType, FormikTouched, useFormik } from "formik"
import { FC, useState } from "react"
import * as Yup from "yup"
import * as TypesGen from "../../api/typesGenerated"
Expand Down Expand Up @@ -35,6 +35,8 @@ export interface CreateWorkspacePageViewProps {
createWorkspaceErrors: Partial<Record<CreateWorkspaceErrors, Error | unknown>>
onCancel: () => void
onSubmit: (req: TypesGen.CreateWorkspaceRequest) => void
// initialTouched is only used for testing the error state of the form.
initialTouched?: FormikTouched<TypesGen.CreateWorkspaceRequest>
}

export const validationSchema = Yup.object({
Expand All @@ -53,6 +55,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = (props)
},
enableReinitialize: true,
validationSchema,
initialTouched: props.initialTouched,
onSubmit: (request) => {
if (!props.templateSchema) {
throw new Error("No template schema loaded")
Expand Down