fix: maas provider custom config
This commit is contained in:
@@ -16,7 +16,7 @@ const AdvanceConfig = () => {
|
||||
const form = Form.useFormInstance();
|
||||
const EnviromentVars = Form.useWatch('env', form);
|
||||
const backend = Form.useWatch('backend', form);
|
||||
const modelAccessEnable = Form.useWatch('enable_model_route', form);
|
||||
const modelRouteEnable = Form.useWatch('enable_model_route', form);
|
||||
const {
|
||||
onValuesChange,
|
||||
backendOptions,
|
||||
@@ -139,15 +139,12 @@ const AdvanceConfig = () => {
|
||||
style={{ marginBottom: 8 }}
|
||||
>
|
||||
<CheckboxField
|
||||
description={intl.formatMessage({
|
||||
id: 'models.form.enable_model_access.tips'
|
||||
})}
|
||||
label={intl.formatMessage({
|
||||
id: 'models.form.enable_model_access'
|
||||
id: 'models.form.enableModelRoute'
|
||||
})}
|
||||
></CheckboxField>
|
||||
</Form.Item>
|
||||
{modelAccessEnable && (
|
||||
{modelRouteEnable && (
|
||||
<Form.Item<FormData>
|
||||
name="generic_proxy"
|
||||
valuePropName="checked"
|
||||
|
||||
@@ -4,6 +4,7 @@ import { PageActionType } from '@/config/types';
|
||||
import CollapsePanel from '@/pages/_components/collapse-panel';
|
||||
import { useWrapperContext } from '@/pages/_components/column-wrapper/use-wrapper-context';
|
||||
import ScrollSpyTabs from '@/pages/_components/scroll-spy-tabs';
|
||||
import { json2Yaml, yaml2Json } from '@/pages/backends/config';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import _ from 'lodash';
|
||||
@@ -41,6 +42,7 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
const { getScrollElementScrollableHeight } = useWrapperContext();
|
||||
const [activeKey, setActiveKey] = useState<string[]>([TABKeysMap.BASIC]);
|
||||
const scrollTabsRef = useRef<any>(null);
|
||||
const advanceRef = useRef<any>(null);
|
||||
|
||||
const segmentOptions = [
|
||||
{
|
||||
@@ -69,7 +71,11 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
);
|
||||
const data = {
|
||||
..._.omit(values, ['api_key']),
|
||||
api_tokens: _.concat([], values.api_key, apiTokens || [])
|
||||
api_tokens: _.concat([], values.api_key, apiTokens || []),
|
||||
config: {
|
||||
type: values.config.type,
|
||||
...yaml2Json(advanceRef.current?.getYamlValue() || '')
|
||||
}
|
||||
};
|
||||
onFinish(data);
|
||||
};
|
||||
@@ -100,7 +106,8 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
...currentData,
|
||||
api_key: currentData.api_tokens?.[0] || '',
|
||||
api_tokens: currentData.api_tokens?.slice(1) || [],
|
||||
proxy_enabled: !!currentData.proxy_url
|
||||
proxy_enabled: !!currentData.proxy_url,
|
||||
custom_config: json2Yaml(_.omit(currentData.config, ['type']) || {})
|
||||
});
|
||||
}
|
||||
}, [form, currentData, action]);
|
||||
@@ -144,7 +151,12 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
key: TABKeysMap.ADVANCED,
|
||||
label: intl.formatMessage({ id: 'resources.form.advanced' }),
|
||||
forceRender: true,
|
||||
children: <AdvanceConfig action={action}></AdvanceConfig>
|
||||
children: (
|
||||
<AdvanceConfig
|
||||
action={action}
|
||||
ref={advanceRef}
|
||||
></AdvanceConfig>
|
||||
)
|
||||
}
|
||||
]}
|
||||
></CollapsePanel>
|
||||
|
||||
@@ -280,11 +280,11 @@ const ModelRoutes: React.FC = () => {
|
||||
image={<IconFont type="icon-extension-outline" />}
|
||||
filters={_.omit(queryParams, ['sort_by'])}
|
||||
noFoundText={intl.formatMessage({
|
||||
id: 'noresult.accesses.nofound'
|
||||
id: 'noresult.routes.nofound'
|
||||
})}
|
||||
title={intl.formatMessage({ id: 'noresult.accesses.title' })}
|
||||
title={intl.formatMessage({ id: 'noresult.routes.title' })}
|
||||
subTitle={intl.formatMessage({
|
||||
id: 'noresult.accesses.subTitle'
|
||||
id: 'noresult.routes.subTitle'
|
||||
})}
|
||||
onClick={handleClickDropdown}
|
||||
buttonText={intl.formatMessage({ id: 'noresult.button.add' })}
|
||||
|
||||
Reference in New Issue
Block a user