fix: click twice for submitting deployment form, using iconfont static files

This commit is contained in:
jialin
2026-05-29 16:19:17 +08:00
committed by jialin
parent 34098e8950
commit 7e048ee537
14 changed files with 3055 additions and 10 deletions
@@ -30,6 +30,7 @@ interface FormContextProps {
flatBackendOptions: BackendOption[];
initialValues?: FormData; // for editing model
modelContextData?: Record<string, any>;
submitAttempted?: boolean;
clearCacheFormValues?: () => void;
onValuesChange?: (changedValues: any, allValues: any) => void;
onBackendChange: (backend: string, option: any) => void;
+5
View File
@@ -101,6 +101,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const [form] = Form.useForm();
const intl = useIntl();
const [activeKey, setActiveKey] = React.useState<string[]>([]);
const [submitAttempted, setSubmitAttempted] = React.useState(false);
const { modelContextData, fetchContextLength } = useQueryContextLength();
const localPath = Form.useWatch('local_path', form);
const modelScopeModelId = Form.useWatch('model_scope_model_id', form);
@@ -229,6 +230,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
..._.omit(data, ['scheduleType']),
...gpuSelector
};
console.log('submit form data:', allValues);
onOk(allValues);
};
@@ -282,6 +284,8 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
};
const handleOnFinishFailed = (errorInfo: any) => {
setSubmitAttempted(true);
console.log('Failed:', errorInfo);
const { errorFields } = errorInfo;
if (errorFields && errorFields.length > 0) {
const collapseKeys: string[] = [];
@@ -398,6 +402,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
workerLabelOptions: workerLabelOptions,
initialValues: initialValues,
modelContextData: modelContextData,
submitAttempted: submitAttempted,
clearCacheFormValues: clearCacheFormValues,
onValuesChange: onValuesChange,
onBackendChange: handleBackendChange
+3 -4
View File
@@ -2,6 +2,7 @@ import { MetadataList } from '@gpustack/core-ui';
import { useIntl } from '@umijs/max';
import { Form } from 'antd';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useFormContext } from '../config/form-context';
import { FormData, LoraListItem } from '../config/types';
import useQueryModelLoraList from '../services/use-query-lora-list';
import LoraItem from './lora-list-item';
@@ -20,9 +21,10 @@ const ModelLoraList = () => {
console.log('fetching lora list with base', base, form.getFieldsValue());
const { dataList: defaultDataList, fetchData } = useQueryModelLoraList();
const { submitAttempted } = useFormContext();
const validated = !!submitAttempted;
const [itemList, setItemList] = useState<ItemValue[]>([]);
const [validated, setValidated] = useState(false);
const initializedRef = useRef(false);
const prevBaseRef = useRef<string>('');
@@ -150,9 +152,6 @@ const ModelLoraList = () => {
rules={[
{
validator: async (_, value: LoraListItem[]) => {
if (!validated) {
setValidated(true);
}
if (!value || value.length === 0) return;
for (const it of value) {