Prevent redirecting to Integrations if you navigated away to a different screen (#1449)
# What this PR does A while ago we fixed a bug where each time you navigated to Integrations, moving to a different a screen would have redirected you back to the Integrations screen if the escalation chain didn't complete loading before you changed the screens. Added a check for `isMounted` which should prevent this bug to appear again in the future.
This commit is contained in:
parent
2db1a5a883
commit
defae434ba
2 changed files with 10 additions and 8 deletions
|
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Fix bug with override creation ([1515](https://github.com/grafana/oncall/pull/1515))
|
||||
- Fixed redirection issue on integrations screen
|
||||
|
||||
## v1.1.35 (2023-03-09)
|
||||
|
||||
|
|
|
|||
|
|
@ -51,18 +51,23 @@ class Integrations extends React.Component<IntegrationsProps, IntegrationsState>
|
|||
errorData: initErrorDataState(),
|
||||
};
|
||||
|
||||
private isMounted: boolean;
|
||||
private alertReceiveChanneltoPoll: { [key: string]: number } = {};
|
||||
private alertReceiveChannelTimerId: ReturnType<typeof setTimeout>;
|
||||
|
||||
async componentDidMount() {
|
||||
this.isMounted = false;
|
||||
this.update().then(() => this.parseQueryParams(true));
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.isMounted = false;
|
||||
clearInterval(this.alertReceiveChannelTimerId);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Readonly<IntegrationsProps>): void {
|
||||
if (prevProps.match.params.id && !this.props.match.params.id) {
|
||||
this.setState({ errorData: initErrorDataState() }, () => {
|
||||
this.parseQueryParams();
|
||||
});
|
||||
this.parseQueryParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +75,7 @@ class Integrations extends React.Component<IntegrationsProps, IntegrationsState>
|
|||
const { store, history } = this.props;
|
||||
store.selectedAlertReceiveChannel = alertReceiveChannelId;
|
||||
|
||||
if (shouldRedirect) {
|
||||
if (shouldRedirect && this.isMounted) {
|
||||
history.push(`${PLUGIN_ROOT}/integrations/${alertReceiveChannelId || ''}`);
|
||||
}
|
||||
};
|
||||
|
|
@ -123,10 +128,6 @@ class Integrations extends React.Component<IntegrationsProps, IntegrationsState>
|
|||
return store.alertReceiveChannelStore.updateItems();
|
||||
};
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.alertReceiveChannelTimerId);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
store,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue