fix: default benchmark form values

This commit is contained in:
jialin
2026-02-02 14:10:46 +08:00
parent fc599a0637
commit f651ab7fd9
15 changed files with 188 additions and 53 deletions
+40 -3
View File
@@ -43,14 +43,46 @@ const DatasetForm: React.FC = () => {
}
};
// Initialize profile when open form
const initProfile = (
value: string,
option: any,
datasetList: Global.BaseOption<number | string>[]
) => {
if (value !== ProfileValueMap.Custom) {
const dataset_id = datasetList.find(
(item) => item.label === option.config?.dataset_name
)?.value;
form.setFieldsValue({
profile: value,
dataset_id: dataset_id,
..._.omit(option?.config, ['description', 'dataset_source'])
});
}
};
useEffect(() => {
if (!open) {
cancelDatasetRequest();
cancelProfilesRequest();
}
if (open) {
fetchProfilesData();
fetchDatasetData();
const init = async () => {
const profiles = await fetchProfilesData();
const datasets = await fetchDatasetData();
// set default profile
if (profiles?.length > 0) {
const throughputProfile = profiles.find(
(item) => item.value === ProfileValueMap.ThroughputMedium
);
if (throughputProfile) {
initProfile(throughputProfile.value, throughputProfile, datasets);
}
}
};
init();
}
}, [open]);
@@ -73,7 +105,12 @@ const DatasetForm: React.FC = () => {
required
>
{profilesOptions?.map((item: any) => (
<Select.Option key={item.value} value={item.value}>
<Select.Option
key={item.value}
value={item.value}
label={item.label}
config={item.config}
>
<AutoTooltip
ghost
showTitle={!!item.tips}