import PluginExtraFields from '@/components/plugin-extra-fields'; import { PageAction } from '@/config'; import { PageActionType } from '@/config/types'; import { Input as CInput, Password, Select as SealSelect } from '@gpustack/core-ui'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; import React from 'react'; import { expirationOptions } from '../../config'; import { FormData, ListItem } from '../../config/types'; import AllowModelsForm from './allow-models'; const APIKeyForm: React.FC<{ action: PageActionType; currentData?: Partial | null; onValuesChange?: (changedValues: any, allValues: any) => void; }> = ({ action, currentData, onValuesChange }) => { const intl = useIntl(); const keyType = Form.useWatch('key_type') as FormData['key_type']; return ( <> name="name" rules={[ { required: true, message: intl.formatMessage( { id: 'common.form.rule.input' }, { name: intl.formatMessage({ id: 'common.table.name' }) } ) } ]} > name="expires_in" rules={[ { required: true, message: intl.formatMessage( { id: 'common.form.rule.select' }, { name: intl.formatMessage({ id: 'apikeys.form.expiretime' }) } ) } ]} > name="description" rules={[{ required: false }]}> {action === PageAction.CREATE && ( <> name="key_type" initialValue="auto"> {keyType === 'custom' && ( name="custom" rules={[ { required: true, message: intl.formatMessage( { id: 'common.form.rule.input' }, { name: intl.formatMessage({ id: 'apikeys.table.key' }) } ) } ]} > )} )} ); }; export default APIKeyForm;