Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix schedule dialog needless confirm saves #3919

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Changes from all commits
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
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