Skip to content

Commit

Permalink
Require loading prop on SideModalForm, fix snapshot create (#2539)
Browse files Browse the repository at this point in the history
require loading prop on side modal form, fix snapshot create
  • Loading branch information
david-crespo authored Nov 7, 2024
1 parent 5edf89e commit 8da7b6d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 3 deletions.
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

0 comments on commit 8da7b6d

Please sign in to comment.