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

[fix issue#4015] webui prompts error message if user set maxExperimentDuration < execDuration #4164

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
'Current duration is more than the number you input, please input effective value',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please input a valid value. (Current duration is ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had changed it to Please input a valid value. (Current duration is more than the number you input.). Please help review again~

'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