From 8458da008da1c95bd5af026e0b324c6ed09b608c Mon Sep 17 00:00:00 2001 From: Ran Byron Date: Thu, 3 Jan 2019 21:34:40 +0200 Subject: [PATCH] Fix: Able to set out-of-range refresh interval --- .../app/components/queries/ScheduleDialog.jsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/app/components/queries/ScheduleDialog.jsx b/client/app/components/queries/ScheduleDialog.jsx index b6d28b2bbc..bbe0dfe8c2 100644 --- a/client/app/components/queries/ScheduleDialog.jsx +++ b/client/app/components/queries/ScheduleDialog.jsx @@ -68,10 +68,6 @@ class ScheduleDialog extends React.Component { }; } - get counts() { - return range(1, INTERVAL_OPTIONS_MAP[this.state.interval]); - } - get intervals() { const ret = this.props.refreshOptions .map((seconds) => { @@ -95,6 +91,8 @@ class ScheduleDialog extends React.Component { }); } + getCounts = interval => range(1, INTERVAL_OPTIONS_MAP[interval]) + setTime = (time) => { this.newSchedule = { time: moment(time).utc().format(HOUR_FORMAT), @@ -128,8 +126,14 @@ class ScheduleDialog extends React.Component { newSchedule.day_of_week = WEEKDAYS_FULL[0]; } + // reset count if out of new interval count range + let count = this.state.count; + if (this.getCounts(newInterval).indexOf(Number(count)) === -1) { + count = '1'; + } + newSchedule.interval = newInterval - ? intervalToSeconds(Number(this.state.count), newInterval) + ? intervalToSeconds(Number(count), newInterval) : null; const [hour, minute] = newSchedule.time ? @@ -138,7 +142,7 @@ class ScheduleDialog extends React.Component { this.setState({ interval: newInterval, - count: newInterval !== IntervalEnum.NEVER ? this.state.count : '1', + count, hour, minute, dayOfWeek: newSchedule.day_of_week @@ -210,7 +214,7 @@ class ScheduleDialog extends React.Component {
{interval !== IntervalEnum.NEVER ? (