Unverified Commit 0ad73ef0 authored by Lijiaoa's avatar Lijiaoa Committed by GitHub
Browse files

[fix issue#4015] webui prompts error message if user set maxExperimentDuration...

[fix issue#4015] webui prompts error message if user set maxExperimentDuration < execDuration (#4164)
parent 8875fa77
......@@ -2,6 +2,7 @@ import React, { useState, useCallback, useContext } from 'react';
import axios from 'axios';
import { Dropdown } from '@fluentui/react';
import { EXPERIMENT } from '../../../static/datamodel';
import { toSeconds } from '../../../static/experimentConfig';
import { AppContext } from '../../../App';
import { EditExpeParamContext } from './context';
import { durationUnit } from '../overviewConst';
......@@ -63,20 +64,32 @@ export const EditExperimentParam = (): any => {
}
}
function promptErrorMessage(mess: string, type: string, value: string): void {
showMessageInfo(mess, type);
setEditValInput(value);
}
async function confirmEdit(): Promise<void> {
const isMaxDuration = title === 'Max duration';
const newProfile = Object.assign({}, EXPERIMENT.profile);
let beforeParam = '';
if (isMaxDuration) {
if (!editInputVal.match(/^\d+(?=\.{0,1}\d+$|$)/)) {
showMessageInfo('Please enter a number!', 'error');
setEditValInput(defaultVal);
promptErrorMessage('Please enter a number!', 'error', defaultVal);
return;
}
if (toSeconds(`${editInputVal}${unit}`) < EXPERIMENT.profile.execDuration) {
// maxDuration should > current run time(execDuration)
promptErrorMessage(
'Please input a valid value. (Current duration is more than the number you input.)',
'error',
defaultVal
);
return;
}
} else {
if (!editInputVal.match(/^[1-9]\d*$/)) {
showMessageInfo('Please enter a positive integer!', 'error');
setEditValInput(defaultVal);
promptErrorMessage('Please enter a positive integer!', 'error', defaultVal);
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment