feat: add loading state when creating workspace
This commit is contained in:
@@ -117,8 +117,11 @@ function NewWorkspaceForm({
|
|||||||
runtimes: WorkspaceRuntime[];
|
runtimes: WorkspaceRuntime[];
|
||||||
onCreateSuccess: () => void;
|
onCreateSuccess: () => void;
|
||||||
}) {
|
}) {
|
||||||
|
const { createWorkspace, status } = useCreateWorkspace();
|
||||||
|
const isCreating = status.type === "loading";
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: superstructResolver(NewWorkspaceFormSchema),
|
resolver: superstructResolver(NewWorkspaceFormSchema),
|
||||||
|
disabled: isCreating,
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
workspaceName: "",
|
workspaceName: "",
|
||||||
// image is in the form "imageTag imageId" (space as separator)
|
// image is in the form "imageTag imageId" (space as separator)
|
||||||
@@ -127,7 +130,6 @@ function NewWorkspaceForm({
|
|||||||
runtime: "",
|
runtime: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { createWorkspace, status } = useCreateWorkspace();
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const formRef = useRef<HTMLFormElement | null>(null);
|
const formRef = useRef<HTMLFormElement | null>(null);
|
||||||
|
|
||||||
@@ -261,7 +263,10 @@ function NewWorkspaceForm({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button type="submit">Create</Button>
|
<Button disabled={isCreating} type="submit">
|
||||||
|
{isCreating ? <LoadingSpinner /> : null}
|
||||||
|
Create
|
||||||
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
Reference in New Issue
Block a user