From f1719bb1790d9350fbb0f385c0d5b13b290d1b49 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Wed, 6 Mar 2024 12:32:15 -0800 Subject: [PATCH] disable form elements when submitting instance create form --- app/components/form/fields/FileField.tsx | 11 ++++++++++- app/components/form/fields/SshKeysField.tsx | 17 +++++++++++++++-- app/forms/instance-create.tsx | 7 ++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/components/form/fields/FileField.tsx b/app/components/form/fields/FileField.tsx index 82ed360556..bf6e5e1150 100644 --- a/app/components/form/fields/FileField.tsx +++ b/app/components/form/fields/FileField.tsx @@ -25,6 +25,7 @@ export function FileField< required = false, accept, description, + disabled, }: { id: string name: TName @@ -34,6 +35,7 @@ export function FileField< required?: boolean accept?: string description?: string | React.ReactNode + disabled?: boolean }) { return ( {description} )} - + )} diff --git a/app/components/form/fields/SshKeysField.tsx b/app/components/form/fields/SshKeysField.tsx index ad0020c6b4..047ddbf838 100644 --- a/app/components/form/fields/SshKeysField.tsx +++ b/app/components/form/fields/SshKeysField.tsx @@ -48,7 +48,13 @@ const CloudInitMessage = () => ( /> ) -export function SshKeysField({ control }: { control: Control }) { +export function SshKeysField({ + control, + isSubmitting, +}: { + control: Control + isSubmitting: boolean +}) { const keys = usePrefetchedApiQuery('currentUserSshKeyList', {}).data?.items || [] const [showAddSshKey, setShowAddSshKey] = useState(false) @@ -85,6 +91,7 @@ export function SshKeysField({ control }: { control: Control {key.name} @@ -101,12 +108,18 @@ export function SshKeysField({ control }: { control: Control onChange(value.length < keys.length ? keys.map((key) => key.id) : []) } + disabled={isSubmitting} > Select all
-
diff --git a/app/forms/instance-create.tsx b/app/forms/instance-create.tsx index ab32d0bc6c..5354a32132 100644 --- a/app/forms/instance-create.tsx +++ b/app/forms/instance-create.tsx @@ -276,13 +276,13 @@ export function CreateInstanceForm() { - + {renderLargeRadioCards('highCPU')} - + {renderLargeRadioCards('highMemory')} @@ -419,7 +419,7 @@ export function CreateInstanceForm() { Authentication - + Advanced @@ -478,6 +478,7 @@ const AdvancedAccordion = ({ name="userData" label="User Data" control={control} + disabled={isSubmitting} />