From 7e9b4600a6981ff700484a8aeabc6aefbdd7e5a7 Mon Sep 17 00:00:00 2001 From: Lijiao Date: Tue, 7 Sep 2021 08:54:49 +0000 Subject: [PATCH 1/2] update --- .../overview/count/EditExperimentParam.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ts/webui/src/components/overview/count/EditExperimentParam.tsx b/ts/webui/src/components/overview/count/EditExperimentParam.tsx index 14ddce08c1..8fc19af014 100644 --- a/ts/webui/src/components/overview/count/EditExperimentParam.tsx +++ b/ts/webui/src/components/overview/count/EditExperimentParam.tsx @@ -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 { 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', + '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; } } From f233caf83d82d6b465529446d114eba254f6343a Mon Sep 17 00:00:00 2001 From: Lijiaoa Date: Mon, 13 Sep 2021 02:02:46 +0000 Subject: [PATCH 2/2] ifix yuge comment:improve tooltip --- ts/webui/src/components/overview/count/EditExperimentParam.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/webui/src/components/overview/count/EditExperimentParam.tsx b/ts/webui/src/components/overview/count/EditExperimentParam.tsx index 8fc19af014..478aa3c2cd 100644 --- a/ts/webui/src/components/overview/count/EditExperimentParam.tsx +++ b/ts/webui/src/components/overview/count/EditExperimentParam.tsx @@ -81,7 +81,7 @@ export const EditExperimentParam = (): any => { 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', + 'Please input a valid value. (Current duration is more than the number you input.)', 'error', defaultVal );