import { PageActionType } from '@/config/types'; import useUserSettings from '@/hooks/use-user-settings'; import { Input as CInput, IconFont } from '@gpustack/core-ui'; import { YamlEditor } from '@gpustack/core-ui/yaml-editor'; import { useIntl } from '@umijs/max'; import { Button, Form } from 'antd'; import React, { forwardRef, useImperativeHandle } from 'react'; import { referLinkEn, referLinkZh } from '../config'; import APIKeys from './api-keys'; import ProxyConfig from './proxy-config'; const AdvanceConfig: React.FC<{ action: PageActionType; ref?: any; }> = forwardRef(({ action }, ref) => { const { isDarkTheme } = useUserSettings(); const form = Form.useFormInstance(); const intl = useIntl(); const editorRef = React.useRef(null); const [fileContent, setFileContent] = React.useState(''); const referLink = intl.locale === 'zh-CN' ? referLinkZh : referLinkEn; useImperativeHandle(ref, () => ({ getYamlValue: () => { return editorRef.current?.getValue(); }, setYamlValue: (values: any) => { console.log('setYamlValue:', values); editorRef.current?.setValue(values || ''); setFileContent(values || ''); } })); return ( <>
{`${intl.formatMessage({ id: 'providers.form.customConfig' })} (YAML)`} } value={fileContent} height={300} onUpload={(content) => { setFileContent(content); }} > ); }); export default AdvanceConfig;