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

fix for webhook
This commit is contained in:
Rares Mardare 2022-10-03 17:33:54 +03:00 committed by GitHub
commit 565c1dc201
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -60,14 +60,19 @@ class OutgoingWebhooks extends React.Component<OutgoingWebhooksProps, OutgoingWe
query: { id },
} = this.props;
if (id) {
const outgoingWebhook = await store.outgoingWebhookStore
if (!id) {return;}
let outgoingWebhook: OutgoingWebhook | void = undefined;
const isNewWebhook = id === 'new';
if (!isNewWebhook) {
outgoingWebhook = await store.outgoingWebhookStore
.loadItem(id, true)
.catch((error) => this.setState({ errorData: { ...getWrongTeamResponseInfo(error) } }));
}
if (outgoingWebhook) {
this.setState({ outgoingWebhookIdToEdit: id });
}
if (outgoingWebhook || isNewWebhook) {
this.setState({ outgoingWebhookIdToEdit: id });
}
};

View file

@ -87,8 +87,8 @@ class SchedulesPage extends React.Component<SchedulesPageProps, SchedulesPageSta
if (!id) {return;}
let scheduleId: string = undefined;
const isNewSchedule = id === 'new';
let scheduleId = undefined;
if (!isNewSchedule) {
// load schedule only for valid id
@ -99,8 +99,7 @@ class SchedulesPage extends React.Component<SchedulesPageProps, SchedulesPageSta
return;
}
const schedules = store.scheduleStore.getSearchResult();
scheduleId = schedules && schedules.find((res) => res.id === id)?.id;
scheduleId = schedule.id;
}
if (scheduleId || isNewSchedule) {