Skip to content

Require loading prop on SideModalForm, fix snapshot create #2539

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 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion app/components/form/SideModalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ type SideModalFormProps<TFieldValues extends FieldValues> = {
resourceName: string
/** Must be provided with a reason describing why it's disabled */
submitDisabled?: string

// require loading and error so we can't forget to hook them up. there are a
// few forms that don't need them, so we'll use dummy values

/** Error from the API call */
submitError: ApiError | null
loading?: boolean
loading: boolean

/** Only needed if you need to override the default title (Create/Edit ${resourceName}) */
title?: string
subtitle?: ReactNode
Expand Down
2 changes: 1 addition & 1 deletion app/forms/disk-attach.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function AttachDiskSideModalForm({
onSubmit,
onDismiss,
diskNamesToExclude = [],
loading,
loading = false,
submitError = null,
}: AttachDiskProps) {
const { project } = useProjectSelector()
Expand Down
1 change: 1 addition & 0 deletions app/forms/idp/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function EditIdpSideModalForm() {
}
// TODO: pass actual error when this form is hooked up
submitError={null}
loading={false}
>
<PropertiesTable>
<PropertiesTable.Row label="ID">
Expand Down
1 change: 1 addition & 0 deletions app/forms/image-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function EditImageSideModalForm({
}
// TODO: pass actual error when this form is hooked up
submitError={null}
loading={false}
>
<PropertiesTable>
<PropertiesTable.Row label="Shared with">{type}</PropertiesTable.Row>
Expand Down
1 change: 1 addition & 0 deletions app/forms/image-from-snapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function CreateImageFromSnapshotSideModalForm() {
})
}
submitError={createImage.error}
loading={createImage.isPending}
>
<PropertiesTable>
<PropertiesTable.Row label="Snapshot">{data.name}</PropertiesTable.Row>
Expand Down
2 changes: 1 addition & 1 deletion app/forms/network-interface-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type CreateNetworkInterfaceFormProps = {
export function CreateNetworkInterfaceForm({
onSubmit,
onDismiss,
loading,
loading = false,
submitError = null,
}: CreateNetworkInterfaceFormProps) {
const projectSelector = useProjectSelector()
Expand Down
1 change: 1 addition & 0 deletions app/forms/snapshot-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function CreateSnapshotSideModalForm() {
createSnapshot.mutate({ query: projectSelector, body: values })
}}
submitError={createSnapshot.error}
loading={createSnapshot.isPending}
>
<NameField name="name" control={form.control} />
<DescriptionField name="description" control={form.control} />
Expand Down
Loading