From 7a8d12a45a61b91528e055f92e853c283daf61ce Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Thu, 14 Dec 2023 11:32:11 -0800 Subject: [PATCH 1/4] Add inputs to silo create form --- app/components/form/fields/TextField.tsx | 1 + app/forms/silo-create.tsx | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/components/form/fields/TextField.tsx b/app/components/form/fields/TextField.tsx index dc53ff6f3c..508f8313b0 100644 --- a/app/components/form/fields/TextField.tsx +++ b/app/components/form/fields/TextField.tsx @@ -53,6 +53,7 @@ export interface TextFieldProps< */ description?: string placeholder?: string + tooltip?: string units?: string validate?: Validate, TFieldValues> control: Control diff --git a/app/forms/silo-create.tsx b/app/forms/silo-create.tsx index 1613e61805..7f846832fe 100644 --- a/app/forms/silo-create.tsx +++ b/app/forms/silo-create.tsx @@ -19,6 +19,7 @@ import { TextField, TlsCertsField, } from 'app/components/form' +import { NumberField } from 'app/components/form/fields/NumberField' import { useForm, useToast } from 'app/hooks' import { pb } from 'app/util/path-builder' @@ -97,6 +98,32 @@ export function CreateSiloSideModalForm() { Discoverable + + + + + Date: Thu, 14 Dec 2023 11:36:13 -0800 Subject: [PATCH 2/4] Remove errant prop --- app/components/form/fields/TextField.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/components/form/fields/TextField.tsx b/app/components/form/fields/TextField.tsx index 508f8313b0..dc53ff6f3c 100644 --- a/app/components/form/fields/TextField.tsx +++ b/app/components/form/fields/TextField.tsx @@ -53,7 +53,6 @@ export interface TextFieldProps< */ description?: string placeholder?: string - tooltip?: string units?: string validate?: Validate, TFieldValues> control: Control From 06e50472804e01b9f89c5f5c909c53cd9f832523 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Thu, 14 Dec 2023 15:52:43 -0600 Subject: [PATCH 3/4] fill fields in e2e test and change disk to storage --- app/forms/silo-create.tsx | 2 +- app/test/e2e/silos.e2e.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/forms/silo-create.tsx b/app/forms/silo-create.tsx index 7f846832fe..d7c3aea0f2 100644 --- a/app/forms/silo-create.tsx +++ b/app/forms/silo-create.tsx @@ -117,7 +117,7 @@ export function CreateSiloSideModalForm() { /> { await page.click('role=link[name="New silo"]') - // fill out form and submit + // fill out form await page.fill('role=textbox[name="Name"]', 'other-silo') await page.fill('role=textbox[name="Description"]', 'definitely a silo') await expect(page.locator('role=checkbox[name="Discoverable"]')).toBeChecked() @@ -33,6 +33,9 @@ test('Create silo', async ({ page }) => { await page.click('role=radio[name="Local only"]') await page.fill('role=textbox[name="Admin group name"]', 'admins') await page.click('role=checkbox[name="Grant fleet admin role to silo admins"]') + await page.getByRole('textbox', { name: 'CPU quota (nCPUs)' }).fill('3') + await page.getByRole('textbox', { name: 'Memory quota (GiB)' }).fill('5') + await page.getByRole('textbox', { name: 'Storage quota (GiB)' }).fill('7') // Add a TLS cert const openCertModalButton = page.getByRole('button', { name: 'Add TLS certificate' }) From c81955e390ee65630ae1730ca3a608831a9ec545 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Thu, 14 Dec 2023 16:00:19 -0600 Subject: [PATCH 4/4] add validation against negative quotas --- app/forms/silo-create.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/forms/silo-create.tsx b/app/forms/silo-create.tsx index d7c3aea0f2..3fafed1b56 100644 --- a/app/forms/silo-create.tsx +++ b/app/forms/silo-create.tsx @@ -44,6 +44,10 @@ const defaultValues: SiloCreateFormValues = { }, } +function validateQuota(value: number) { + if (value < 0) return 'Must be at least 0' +} + export function CreateSiloSideModalForm() { const navigate = useNavigate() const queryClient = useApiQueryClient() @@ -106,6 +110,7 @@ export function CreateSiloSideModalForm() { required type="number" units="nCPUs" + validate={validateQuota} />