From 07ccefee65ac0f99741e339a61f6ea174e498f19 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Wed, 4 Sep 2024 13:32:04 -0700 Subject: [PATCH] Refactoring --- app/components/form/fields/ComboboxField.tsx | 10 ++++++---- app/forms/disk-attach.tsx | 1 - app/forms/firewall-rules-common.tsx | 10 ++++++---- app/forms/snapshot-create.tsx | 1 - app/pages/system/SiloImagesPage.tsx | 1 - 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/components/form/fields/ComboboxField.tsx b/app/components/form/fields/ComboboxField.tsx index 4be1afdf1e..df580fdd5a 100644 --- a/app/components/form/fields/ComboboxField.tsx +++ b/app/components/form/fields/ComboboxField.tsx @@ -41,10 +41,12 @@ export function ComboboxField< allowArbitraryValues, placeholder, // Intent is to not show both a placeholder and a description, while still having good defaults; prefer a description to a placeholder - // If description is provided, use it - // If not, but a placeholder is provided, the default description should be undefined - // If no placeholder is provided and arbitrary values are allowed, the default description should be 'Select an option or enter a custom value' - // If no placeholder is provided and arbitrary values are not allowed, the default description should be 'Select an option' + /* + * If description is provided, use it. + * If not, but a placeholder is provided, the default description should be undefined. + * If no placeholder is provided and arbitrary values are allowed, the default description should be 'Select an option or enter a custom value'. + * If no placeholder is provided and arbitrary values are not allowed, the default description should be 'Select an option'. + */ description = placeholder ? undefined : allowArbitraryValues diff --git a/app/forms/disk-attach.tsx b/app/forms/disk-attach.tsx index b5ab3b22d3..7895c81b91 100644 --- a/app/forms/disk-attach.tsx +++ b/app/forms/disk-attach.tsx @@ -57,7 +57,6 @@ export function AttachDiskSideModalForm({ ({ value: name, label: name }))} required diff --git a/app/forms/firewall-rules-common.tsx b/app/forms/firewall-rules-common.tsx index 97c09b9e2d..4edc950ed5 100644 --- a/app/forms/firewall-rules-common.tsx +++ b/app/forms/firewall-rules-common.tsx @@ -286,14 +286,16 @@ export const CommonFields = ({ control, nameTaken, error }: CommonFieldsProps) = const targetAndHostDefaultValues: TargetAndHostFormValues = { type: 'vpc', value: '' } const { project } = useProjectSelector() // prefetchedApiQueries below are prefetched in firewall-rules-create and -edit - const { data: instancesData } = usePrefetchedApiQuery('instanceList', { + const { + data: { items: instances }, + } = usePrefetchedApiQuery('instanceList', { query: { project, limit: PAGE_SIZE }, }) - const instances = instancesData?.items ?? [] - const { data: vpcData } = usePrefetchedApiQuery('vpcList', { + const { + data: { items: vpcs }, + } = usePrefetchedApiQuery('vpcList', { query: { project, limit: PAGE_SIZE }, }) - const vpcs = vpcData?.items ?? [] // Targets const targetForm = useForm({ defaultValues: targetAndHostDefaultValues }) diff --git a/app/forms/snapshot-create.tsx b/app/forms/snapshot-create.tsx index 50514aea83..0080251420 100644 --- a/app/forms/snapshot-create.tsx +++ b/app/forms/snapshot-create.tsx @@ -77,7 +77,6 @@ export function CreateSnapshotSideModalForm() { label="Disk" name="disk" placeholder="Select a disk" - description="" items={diskItems} required control={form.control} diff --git a/app/pages/system/SiloImagesPage.tsx b/app/pages/system/SiloImagesPage.tsx index d2611830cd..c8f92d5937 100644 --- a/app/pages/system/SiloImagesPage.tsx +++ b/app/pages/system/SiloImagesPage.tsx @@ -170,7 +170,6 @@ const PromoteImageModal = ({ onDismiss }: { onDismiss: () => void }) => {