diff --git a/webui/src/components/ZodFormField.tsx b/webui/src/components/ZodFormField.tsx deleted file mode 100644 index 594d907..0000000 --- a/webui/src/components/ZodFormField.tsx +++ /dev/null @@ -1,144 +0,0 @@ -import React from 'react' -import { Input } from '@/components/ui/input' -import { Label } from '@/components/ui/label' -import { Checkbox } from '@/components/ui/checkbox' -import { BackendType, type CreateInstanceOptions } from '@/types/instance' -import { getFieldType, basicFieldsConfig } from '@/lib/zodFormUtils' - -interface ZodFormFieldProps { - fieldKey: keyof CreateInstanceOptions - value: string | number | boolean | string[] | undefined - onChange: (key: keyof CreateInstanceOptions, value: string | number | boolean | string[] | undefined) => void -} - -const ZodFormField: React.FC = ({ fieldKey, value, onChange }) => { - // Get configuration for basic fields, or use field name for advanced fields - const config = basicFieldsConfig[fieldKey as string] || { label: fieldKey } - - // Get type from Zod schema - const fieldType = getFieldType(fieldKey) - - const handleChange = (newValue: string | number | boolean | string[] | undefined) => { - onChange(fieldKey, newValue) - } - - const renderField = () => { - // Special handling for backend_type field - render as dropdown - if (fieldKey === 'backend_type') { - return ( -
- - - {config.description && ( -

{config.description}

- )} -
- ) - } - - switch (fieldType) { - case 'boolean': - return ( -
- handleChange(checked)} - /> - -
- ) - - case 'number': - return ( -
- - { - const numValue = e.target.value ? parseFloat(e.target.value) : undefined - // Only update if the parsed value is valid or the input is empty - if (e.target.value === '' || (numValue !== undefined && !isNaN(numValue))) { - handleChange(numValue) - } - }} - placeholder={config.placeholder} - /> - {config.description && ( -

{config.description}

- )} -
- ) - - case 'array': - return ( -
- - { - const arrayValue = e.target.value - ? e.target.value.split(',').map(s => s.trim()).filter(Boolean) - : undefined - handleChange(arrayValue) - }} - placeholder="item1, item2, item3" - /> - {config.description && ( -

{config.description}

- )} -

Separate multiple values with commas

-
- ) - - case 'text': - default: - return ( -
- - handleChange(e.target.value || undefined)} - placeholder={config.placeholder} - /> - {config.description && ( -

{config.description}

- )} -
- ) - } - } - - return
{renderField()}
-} - -export default ZodFormField \ No newline at end of file diff --git a/webui/src/components/instance/BasicInstanceFields.tsx b/webui/src/components/instance/BasicInstanceFields.tsx deleted file mode 100644 index 9dce284..0000000 --- a/webui/src/components/instance/BasicInstanceFields.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import React from 'react' -import { BackendType, type CreateInstanceOptions } from '@/types/instance' -import { getBasicFields, basicFieldsConfig } from '@/lib/zodFormUtils' -import { getFieldType } from '@/schemas/instanceOptions' -import TextInput from '@/components/form/TextInput' -import NumberInput from '@/components/form/NumberInput' -import CheckboxInput from '@/components/form/CheckboxInput' -import SelectInput from '@/components/form/SelectInput' - -interface BasicInstanceFieldsProps { - formData: CreateInstanceOptions - onChange: (key: keyof CreateInstanceOptions, value: any) => void -} - -const BasicInstanceFields: React.FC = ({ - formData, - onChange -}) => { - const basicFields = getBasicFields() - - const renderField = (fieldKey: keyof CreateInstanceOptions) => { - const config = basicFieldsConfig[fieldKey as string] || { label: fieldKey } - const fieldType = getFieldType(fieldKey) - - // Special handling for backend_type field - if (fieldKey === 'backend_type') { - return ( - onChange(fieldKey, value)} - options={[ - { value: BackendType.LLAMA_CPP, label: 'Llama Server' }, - { value: BackendType.MLX_LM, label: 'MLX LM' }, - { value: BackendType.VLLM, label: 'vLLM' } - ]} - description={config.description} - /> - ) - } - - // Render based on field type - switch (fieldType) { - case 'boolean': - return ( - onChange(fieldKey, value)} - description={config.description} - /> - ) - - case 'number': - return ( - onChange(fieldKey, value)} - placeholder={config.placeholder} - description={config.description} - /> - ) - - default: - return ( - onChange(fieldKey, value)} - placeholder={config.placeholder} - description={config.description} - /> - ) - } - } - - // Filter out auto restart fields and backend_options (handled separately) - const fieldsToRender = basicFields.filter( - fieldKey => !['auto_restart', 'max_restarts', 'restart_delay', 'backend_options'].includes(fieldKey as string) - ) - - return ( -
-

Basic Configuration

- {fieldsToRender.map(renderField)} -
- ) -} - -export default BasicInstanceFields \ No newline at end of file