From b20204acd815e36318f16766a226a90c8ea36221 Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Fri, 15 Apr 2022 15:05:59 -0400 Subject: [PATCH] Merge libs/form into app --- {libs => app/components}/form/Form.tsx | 0 {libs => app/components}/form/fields/DescriptionField.tsx | 0 app/components/{ => form}/fields/DisksTableField.tsx | 2 +- {libs => app/components}/form/fields/NameField.spec.tsx | 0 {libs => app/components}/form/fields/NameField.tsx | 0 app/components/{ => form}/fields/NetworkInterfaceField.tsx | 2 +- {libs => app/components}/form/fields/RadioField.tsx | 0 {libs => app/components}/form/fields/TagsField.tsx | 0 {libs => app/components}/form/fields/TextField.tsx | 4 ++-- {libs => app/components}/form/fields/index.ts | 2 ++ {libs => app/components}/form/form.css | 0 {libs => app/components}/form/index.ts | 0 app/forms/disk-attach.tsx | 2 +- app/forms/disk-create.tsx | 2 +- app/forms/index.ts | 2 +- app/forms/instance-create.tsx | 6 +++--- app/forms/network-interface-create.tsx | 2 +- app/forms/org-create.tsx | 2 +- app/forms/project-create.tsx | 2 +- app/forms/subnet-create.tsx | 2 +- app/forms/vpc-create.tsx | 2 +- libs/form/hooks/useError.tsx => app/hooks/useFieldError.tsx | 2 +- app/layouts/OrgLayout.tsx | 2 +- app/layouts/ProjectLayout.tsx | 2 +- app/layouts/RootLayout.tsx | 2 +- tsconfig.json | 1 - 26 files changed, 21 insertions(+), 20 deletions(-) rename {libs => app/components}/form/Form.tsx (100%) rename {libs => app/components}/form/fields/DescriptionField.tsx (100%) rename app/components/{ => form}/fields/DisksTableField.tsx (98%) rename {libs => app/components}/form/fields/NameField.spec.tsx (100%) rename {libs => app/components}/form/fields/NameField.tsx (100%) rename app/components/{ => form}/fields/NetworkInterfaceField.tsx (98%) rename {libs => app/components}/form/fields/RadioField.tsx (100%) rename {libs => app/components}/form/fields/TagsField.tsx (100%) rename {libs => app/components}/form/fields/TextField.tsx (95%) rename {libs => app/components}/form/fields/index.ts (66%) rename {libs => app/components}/form/form.css (100%) rename {libs => app/components}/form/index.ts (100%) rename libs/form/hooks/useError.tsx => app/hooks/useFieldError.tsx (66%) diff --git a/libs/form/Form.tsx b/app/components/form/Form.tsx similarity index 100% rename from libs/form/Form.tsx rename to app/components/form/Form.tsx diff --git a/libs/form/fields/DescriptionField.tsx b/app/components/form/fields/DescriptionField.tsx similarity index 100% rename from libs/form/fields/DescriptionField.tsx rename to app/components/form/fields/DescriptionField.tsx diff --git a/app/components/fields/DisksTableField.tsx b/app/components/form/fields/DisksTableField.tsx similarity index 98% rename from app/components/fields/DisksTableField.tsx rename to app/components/form/fields/DisksTableField.tsx index 64a8ed37b9..c6e373a30f 100644 --- a/app/components/fields/DisksTableField.tsx +++ b/app/components/form/fields/DisksTableField.tsx @@ -3,7 +3,7 @@ import { useField } from 'formik' import { CreateDiskForm } from 'app/forms/disk-create' import { AttachDiskForm } from 'app/forms/disk-attach' import { Button, Error16Icon, FieldLabel, MiniTable, SideModal } from '@oxide/ui' -import type { FormValues } from '../../forms' +import type { FormValues } from 'app/forms' type DiskTableItem = | (FormValues<'disk-create'> & { type: 'create' }) diff --git a/libs/form/fields/NameField.spec.tsx b/app/components/form/fields/NameField.spec.tsx similarity index 100% rename from libs/form/fields/NameField.spec.tsx rename to app/components/form/fields/NameField.spec.tsx diff --git a/libs/form/fields/NameField.tsx b/app/components/form/fields/NameField.tsx similarity index 100% rename from libs/form/fields/NameField.tsx rename to app/components/form/fields/NameField.tsx diff --git a/app/components/fields/NetworkInterfaceField.tsx b/app/components/form/fields/NetworkInterfaceField.tsx similarity index 98% rename from app/components/fields/NetworkInterfaceField.tsx rename to app/components/form/fields/NetworkInterfaceField.tsx index bb3d5fcf6d..07fa559a3e 100644 --- a/app/components/fields/NetworkInterfaceField.tsx +++ b/app/components/form/fields/NetworkInterfaceField.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react' import { useField } from 'formik' import { Button, Error16Icon, MiniTable, Radio, SideModal } from '@oxide/ui' import type { InstanceNetworkInterfaceAttachment, NetworkInterfaceCreate } from '@oxide/api' -import { RadioField } from '@oxide/form' +import { RadioField } from 'app/components/form' import CreateNetworkInterfaceForm from 'app/forms/network-interface-create' export function NetworkInterfaceField() { diff --git a/libs/form/fields/RadioField.tsx b/app/components/form/fields/RadioField.tsx similarity index 100% rename from libs/form/fields/RadioField.tsx rename to app/components/form/fields/RadioField.tsx diff --git a/libs/form/fields/TagsField.tsx b/app/components/form/fields/TagsField.tsx similarity index 100% rename from libs/form/fields/TagsField.tsx rename to app/components/form/fields/TagsField.tsx diff --git a/libs/form/fields/TextField.tsx b/app/components/form/fields/TextField.tsx similarity index 95% rename from libs/form/fields/TextField.tsx rename to app/components/form/fields/TextField.tsx index eea10d4c4b..13a05ccd17 100644 --- a/libs/form/fields/TextField.tsx +++ b/app/components/form/fields/TextField.tsx @@ -5,7 +5,7 @@ import { FieldLabel, TextField as UITextField } from '@oxide/ui' import { capitalize } from '@oxide/util' import cn from 'classnames' import React from 'react' -import { useError } from '../hooks/useError' +import { useFieldError } from '../../../hooks/useFieldError' export interface TextFieldProps extends UITextFieldProps { id: string @@ -39,7 +39,7 @@ export function TextField({ ...props }: TextFieldProps) { const { description, helpText, required } = props - const error = useError(name) + const error = useFieldError(name) return (
diff --git a/libs/form/fields/index.ts b/app/components/form/fields/index.ts similarity index 66% rename from libs/form/fields/index.ts rename to app/components/form/fields/index.ts index 8777a1d04c..4a9bae8264 100644 --- a/libs/form/fields/index.ts +++ b/app/components/form/fields/index.ts @@ -3,3 +3,5 @@ export * from './TextField' export * from './NameField' export * from './TagsField' export * from './RadioField' +export * from './NetworkInterfaceField' +export * from './DisksTableField' diff --git a/libs/form/form.css b/app/components/form/form.css similarity index 100% rename from libs/form/form.css rename to app/components/form/form.css diff --git a/libs/form/index.ts b/app/components/form/index.ts similarity index 100% rename from libs/form/index.ts rename to app/components/form/index.ts diff --git a/app/forms/disk-attach.tsx b/app/forms/disk-attach.tsx index 7825c178f7..7093754b72 100644 --- a/app/forms/disk-attach.tsx +++ b/app/forms/disk-attach.tsx @@ -1,4 +1,4 @@ -import { Form, NameField } from '@oxide/form' +import { Form, NameField } from 'app/components/form' import React from 'react' import type { Disk } from '@oxide/api' import { useApiMutation, useApiQueryClient } from '@oxide/api' diff --git a/app/forms/disk-create.tsx b/app/forms/disk-create.tsx index 78a8df4834..c2faf6a89b 100644 --- a/app/forms/disk-create.tsx +++ b/app/forms/disk-create.tsx @@ -6,7 +6,7 @@ import { TextField, RadioField, Radio, -} from '@oxide/form' +} from 'app/components/form' import { Divider } from '@oxide/ui' import type { Disk } from '@oxide/api' import { useApiMutation, useApiQueryClient } from '@oxide/api' diff --git a/app/forms/index.ts b/app/forms/index.ts index fcf7778fee..eaf1918771 100644 --- a/app/forms/index.ts +++ b/app/forms/index.ts @@ -10,7 +10,7 @@ import type CreateInstanceForm from './instance-create' import type AttachDiskForm from './disk-attach' import type CreateNetworkInterfaceForm from './network-interface-create' -import type { FormProps } from '@oxide/form' +import type { FormProps } from 'app/components/form' import type { ErrorResponse } from '@oxide/api' import type { ComponentType } from 'react' diff --git a/app/forms/instance-create.tsx b/app/forms/instance-create.tsx index ae14022de1..983f40176c 100644 --- a/app/forms/instance-create.tsx +++ b/app/forms/instance-create.tsx @@ -4,12 +4,14 @@ import { useApiMutation, useApiQueryClient } from '@oxide/api' import type { PrebuiltFormProps } from 'app/forms' import { DescriptionField, + DisksTableField, Form, NameField, + NetworkInterfaceField, RadioField, TagsField, TextField, -} from '@oxide/form' +} from 'app/components/form' import { CentOSResponsiveIcon, DebianResponsiveIcon, @@ -25,9 +27,7 @@ import { WindowsResponsiveIcon, } from '@oxide/ui' import { useParams, useToast } from 'app/hooks' -import { DisksTableField } from 'app/components/fields/DisksTableField' import filesize from 'filesize' -import { NetworkInterfaceField } from 'app/components/fields/NetworkInterfaceField' const values = { name: '', diff --git a/app/forms/network-interface-create.tsx b/app/forms/network-interface-create.tsx index 49b88f191d..74a661bec8 100644 --- a/app/forms/network-interface-create.tsx +++ b/app/forms/network-interface-create.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { DescriptionField, Form, NameField, TextField } from '@oxide/form' +import { DescriptionField, Form, NameField, TextField } from 'app/components/form' import { Divider } from '@oxide/ui' import type { NetworkInterfaceCreate, NetworkInterface } from '@oxide/api' import { useApiMutation, useApiQueryClient } from '@oxide/api' diff --git a/app/forms/org-create.tsx b/app/forms/org-create.tsx index fc34d629e4..2c0b99bc0e 100644 --- a/app/forms/org-create.tsx +++ b/app/forms/org-create.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { Form, NameField, DescriptionField } from '@oxide/form' +import { Form, NameField, DescriptionField } from 'app/components/form' import type { Organization } from '@oxide/api' import { useApiMutation, useApiQueryClient } from '@oxide/api' import { useToast } from 'app/hooks' diff --git a/app/forms/project-create.tsx b/app/forms/project-create.tsx index a4f6cc77a2..781fc823a9 100644 --- a/app/forms/project-create.tsx +++ b/app/forms/project-create.tsx @@ -4,7 +4,7 @@ import { Success16Icon } from '@oxide/ui' import type { Project } from '@oxide/api' import { useApiMutation, useApiQueryClient } from '@oxide/api' import { useParams, useToast } from '../hooks' -import { Form, NameField, DescriptionField } from '@oxide/form' +import { Form, NameField, DescriptionField } from 'app/components/form' import type { PrebuiltFormProps } from 'app/forms' const values = { diff --git a/app/forms/subnet-create.tsx b/app/forms/subnet-create.tsx index 61989deef0..29f358ffe7 100644 --- a/app/forms/subnet-create.tsx +++ b/app/forms/subnet-create.tsx @@ -1,4 +1,4 @@ -import { DescriptionField, Form, NameField, TextField } from '@oxide/form' +import { DescriptionField, Form, NameField, TextField } from 'app/components/form' import { Divider } from '@oxide/ui' import React from 'react' import type { VpcSubnet } from '@oxide/api' diff --git a/app/forms/vpc-create.tsx b/app/forms/vpc-create.tsx index a190d8ac72..4784ecd051 100644 --- a/app/forms/vpc-create.tsx +++ b/app/forms/vpc-create.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { Form, NameField, DescriptionField, TextField } from '@oxide/form' +import { Form, NameField, DescriptionField, TextField } from 'app/components/form' import type { Vpc } from '@oxide/api' import { useApiMutation, useApiQueryClient } from '@oxide/api' import { useParams, useToast } from 'app/hooks' diff --git a/libs/form/hooks/useError.tsx b/app/hooks/useFieldError.tsx similarity index 66% rename from libs/form/hooks/useError.tsx rename to app/hooks/useFieldError.tsx index b376e7aae3..46cd0fd1bc 100644 --- a/libs/form/hooks/useError.tsx +++ b/app/hooks/useFieldError.tsx @@ -1,6 +1,6 @@ import { useFormikContext } from 'formik' -export const useError = (name: string): string | undefined => { +export const useFieldError = (name: string): string | undefined => { const { errors } = useFormikContext() return (errors as Record)[name] } diff --git a/app/layouts/OrgLayout.tsx b/app/layouts/OrgLayout.tsx index bb580d0fc6..55c1078bd0 100644 --- a/app/layouts/OrgLayout.tsx +++ b/app/layouts/OrgLayout.tsx @@ -16,7 +16,7 @@ import { Sidebar, NavLinkItem } from '../components/Sidebar' import { PageHeader } from '../components/PageHeader' import { Pagination } from '@oxide/pagination' import { SkipLinkTarget } from '@oxide/ui' -import { Form } from '@oxide/form' +import { Form } from 'app/components/form' const OrgLayout = () => { const { orgName } = useParams('orgName') diff --git a/app/layouts/ProjectLayout.tsx b/app/layouts/ProjectLayout.tsx index e52e2658d6..5d52bca417 100644 --- a/app/layouts/ProjectLayout.tsx +++ b/app/layouts/ProjectLayout.tsx @@ -22,7 +22,7 @@ import { Sidebar, NavLinkItem } from '../components/Sidebar' import { PageHeader } from '../components/PageHeader' import { useParams, useQuickActions } from 'app/hooks' import { Pagination } from '@oxide/pagination' -import { Form } from '@oxide/form' +import { Form } from 'app/components/form' const ProjectLayout = () => { const navigate = useNavigate() diff --git a/app/layouts/RootLayout.tsx b/app/layouts/RootLayout.tsx index 790f6558cf..2a0ff01277 100644 --- a/app/layouts/RootLayout.tsx +++ b/app/layouts/RootLayout.tsx @@ -13,7 +13,7 @@ import { Breadcrumbs } from '../components/Breadcrumbs' import { TopBar } from '../components/TopBar' import { PageHeader } from '../components/PageHeader' import { Pagination } from '@oxide/pagination' -import { Form } from '@oxide/form' +import { Form } from 'app/components/form' const RootLayout = () => { return ( diff --git a/tsconfig.json b/tsconfig.json index 55a6e414ec..f35dca197f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,6 @@ "@oxide/api-mocks": ["libs/api-mocks/index.ts"], "@oxide/ui": ["libs/ui/index.ts"], "@oxide/util": ["libs/util/index.ts"], - "@oxide/form": ["libs/form/index.ts"], "@oxide/table": ["libs/table/index.ts"], "@oxide/pagination": ["libs/pagination/index.ts"] },