From 21ffd2a564eee8e3cac58924fb7ef9f742d71342 Mon Sep 17 00:00:00 2001 From: jialin Date: Sat, 7 Feb 2026 16:49:17 +0800 Subject: [PATCH] fix: env params incorrect after switching between vendors --- src/components/copy-button/index.tsx | 1 - src/components/seal-form/password.tsx | 5 ++++- src/components/seal-form/wrapper/select.ts | 4 ++-- src/global.less | 2 +- src/pages/benchmark/components/environment/index.tsx | 8 ++++---- .../components/add-worker/select-vendor.tsx | 2 +- src/pages/maas-provider/forms/basic.tsx | 7 ++++++- src/pages/resources/config/gpu-driver.ts | 10 ++++++---- 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/components/copy-button/index.tsx b/src/components/copy-button/index.tsx index a23e71bb..7f6e9acf 100644 --- a/src/components/copy-button/index.tsx +++ b/src/components/copy-button/index.tsx @@ -50,7 +50,6 @@ const CopyButton: React.FC = ({ return ( = (props) => { +const SealPassword: React.FC = ( + props +) => { const { label, placeholder, diff --git a/src/components/seal-form/wrapper/select.ts b/src/components/seal-form/wrapper/select.ts index 09c17100..a0085484 100644 --- a/src/components/seal-form/wrapper/select.ts +++ b/src/components/seal-form/wrapper/select.ts @@ -13,7 +13,7 @@ const SelectWrapper = styled.div` border-color: var(--ant-input-active-border-color) !important; outline: 0; background-color: var(--ant-input-active-bg); - border-bottom: none !important; + border-bottom-color: transparent !important; border-radius: ${BORDERRADIUS}px ${BORDERRADIUS}px 0 0; transition: all 0.2s ease; box-shadow: none; @@ -24,7 +24,7 @@ const SelectWrapper = styled.div` height: 1px; margin-inline: 1px; bottom: 0; - left: 0; + left: 0px; right: 0; background-color: var(--ant-color-split); } diff --git a/src/global.less b/src/global.less index 62309c96..8806b59b 100644 --- a/src/global.less +++ b/src/global.less @@ -647,7 +647,7 @@ body { .cascader-popup-wrapper { width: 100%; border: 1px solid var(--ant-color-border); - inset: 54px auto auto 0 !important; + inset: 53px auto auto 0 !important; border-radius: 0 0 var(--border-radius-base) var(--border-radius-base); border-top: none; max-height: 240px; diff --git a/src/pages/benchmark/components/environment/index.tsx b/src/pages/benchmark/components/environment/index.tsx index c2228180..6fd96bdd 100644 --- a/src/pages/benchmark/components/environment/index.tsx +++ b/src/pages/benchmark/components/environment/index.tsx @@ -30,7 +30,7 @@ const Environment: React.FC = () => { const { snapshot } = detailData; // instance info - const instanceEntry = Object.entries(snapshot.instances ?? {})[0]; + const instanceEntry = Object.entries(snapshot.instances || {})[0]; const instanceData = instanceEntry?.[1]; const { handleExpandChange, handleExpandAll, expandedRowKeys } = @@ -38,7 +38,7 @@ const Environment: React.FC = () => { const workerMap = useMemo(() => { return new Map( - Object.entries(snapshot.workers ?? {}).map(([workerName, workerInfo]) => [ + Object.entries(snapshot.workers || {}).map(([workerName, workerInfo]) => [ workerInfo.id, workerInfo ]) @@ -46,7 +46,7 @@ const Environment: React.FC = () => { }, [snapshot.workers]); const gpuList = useMemo(() => { - return Object.values(snapshot.gpus ?? {}) || []; + return Object.values(snapshot.gpus || {}) || []; }, [snapshot.gpus]); const findWorkerById = (workerID: number): WorkerData | undefined => { @@ -97,7 +97,7 @@ const Environment: React.FC = () => { children: gpuData }; }); - }, [snapshot]); + }, [snapshot.gpus, snapshot.workers, instanceData]); const dataList = useMemo(() => { return [mainWorker, ...subWorkerList].filter(Boolean) as WorkerData[]; diff --git a/src/pages/cluster-management/components/add-worker/select-vendor.tsx b/src/pages/cluster-management/components/add-worker/select-vendor.tsx index ef770991..26891cef 100644 --- a/src/pages/cluster-management/components/add-worker/select-vendor.tsx +++ b/src/pages/cluster-management/components/add-worker/select-vendor.tsx @@ -20,7 +20,7 @@ const SelectVendor: React.FC = ({ disabled }) => { ); const handleSelectProvider = (value: string, item: any) => { - console.log('selected gpu driver:', value, item); + if (value === currentGPU) return; setCurrentGPU(value); updateField('currentGPU', value); diff --git a/src/pages/maas-provider/forms/basic.tsx b/src/pages/maas-provider/forms/basic.tsx index 7170febd..2f6f1f0e 100644 --- a/src/pages/maas-provider/forms/basic.tsx +++ b/src/pages/maas-provider/forms/basic.tsx @@ -1,9 +1,12 @@ +import Password from '@/components/seal-form/password'; import SealInput from '@/components/seal-form/seal-input'; import SealSelect from '@/components/seal-form/seal-select'; +import { PageAction } from '@/config'; import useAppUtils from '@/hooks/use-app-utils'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; import ProviderLogo from '../components/provider-logo'; +import { useFormContext } from '../config/form-context'; import { maasProviderOptions, ProviderEnum } from '../config/providers'; import { FormData } from '../config/types'; @@ -12,6 +15,7 @@ const Basic: React.FC<{ }> = ({ onAPIKeyBlur }) => { const intl = useIntl(); const form = Form.useFormInstance(); + const { action } = useFormContext(); const providerType = Form.useWatch(['config', 'type'], form); const { getRuleMessage } = useAppUtils(); @@ -92,8 +96,9 @@ const Basic: React.FC<{ } ]} > - { - const registrationInfo = params.registrationInfo || {}; - registrationInfo.env = { - ...registrationInfo.env, - ...params.extraEnv + const registrationInfo = { + ...params.registrationInfo, + env: { + ...(params.registrationInfo?.env || {}), + ...params.extraEnv + } }; // generate environment variables args from registrationInfo.env let envArgs = '';