Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
[fix issue#4015] webui prompts error message if user set maxExperimen…
Browse files Browse the repository at this point in the history
…tDuration < execDuration (#4164)
  • Loading branch information
Lijiaoa authored Sep 15, 2021
1 parent 8875fa7 commit 0ad73ef
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions ts/webui/src/components/overview/count/EditExperimentParam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 0ad73ef

Please sign in to comment.