Merge pull request #600 from grafana/rares/fix-schedule-id=new

schedules fix
This commit is contained in:
Maxim Mordasov 2022-10-03 16:49:30 +03:00 committed by GitHub
commit 58b681f075
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,7 +85,13 @@ class SchedulesPage extends React.Component<SchedulesPageProps, SchedulesPageSta
query: { id },
} = this.props;
if (id) {
if (!id) {return;}
const isNewSchedule = id === 'new';
let scheduleId = undefined;
if (!isNewSchedule) {
// load schedule only for valid id
const schedule = await store.scheduleStore
.loadItem(id, true)
.catch((error) => this.setState({ errorData: { ...getWrongTeamResponseInfo(error) } }));
@ -94,12 +100,13 @@ class SchedulesPage extends React.Component<SchedulesPageProps, SchedulesPageSta
}
const schedules = store.scheduleStore.getSearchResult();
const scheduleId = schedules && schedules.find((res) => res.id === id)?.id;
if (scheduleId || id === 'new') {
this.setState({ scheduleIdToEdit: id });
} else {
openErrorNotification(`Schedule with id=${id} is not found. Please select schedule from the list.`);
}
scheduleId = schedules && schedules.find((res) => res.id === id)?.id;
}
if (scheduleId || isNewSchedule) {
this.setState({ scheduleIdToEdit: id });
} else {
openErrorNotification(`Schedule with id=${id} is not found. Please select schedule from the list.`);
}
};