Skip to content

Commit

Permalink
Fix schedule dialog needless confirm saves (getredash#3919)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena authored and harveyrendell committed Nov 14, 2019
1 parent e1e918b commit 0374ba9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/app/components/queries/ScheduleDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DatePicker from 'antd/lib/date-picker';
import TimePicker from 'antd/lib/time-picker';
import Select from 'antd/lib/select';
import Radio from 'antd/lib/radio';
import { capitalize, clone, isEqual } from 'lodash';
import { capitalize, clone, isEqual, omitBy, isNil } from 'lodash';
import moment from 'moment';
import { secondsToInterval, durationHumanize, pluralize, IntervalEnum, localizeTime } from '@/filters';
import { wrap as wrapDialog, DialogPropType } from '@/components/DialogWrapper';
Expand Down Expand Up @@ -177,9 +177,14 @@ class ScheduleDialog extends React.Component {

save() {
const { newSchedule } = this.state;
const hasChanged = () => {
const newCompact = omitBy(newSchedule, isNil);
const oldCompact = omitBy(this.props.schedule, isNil);
return !isEqual(newCompact, oldCompact);
};

// save if changed
if (!isEqual(newSchedule, this.props.schedule)) {
if (hasChanged()) {
if (newSchedule.interval) {
this.props.dialog.close(clone(newSchedule));
} else {
Expand Down

0 comments on commit 0374ba9

Please sign in to comment.