diff --git a/CHANGELOG.md b/CHANGELOG.md index 15932fff..36ead2eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fix issue on Integrations where you were redirected back once escalation chain was loaded ([#1083](https://github.com/grafana/oncall/issues/1083)) + ([#1257](https://github.com/grafana/oncall/issues/1257)) + ## v1.1.20 (2023-01-30) ### Added diff --git a/grafana-plugin/src/containers/AlertRules/AlertRules.tsx b/grafana-plugin/src/containers/AlertRules/AlertRules.tsx index c696a0e9..fe9f35ee 100644 --- a/grafana-plugin/src/containers/AlertRules/AlertRules.tsx +++ b/grafana-plugin/src/containers/AlertRules/AlertRules.tsx @@ -255,7 +255,7 @@ class AlertRules extends React.Component { tooltip="Settings" tooltipPlacement="top" onClick={() => { - onShowSettings(); + onShowSettings(IntegrationSettingsTab.Templates); }} /> diff --git a/grafana-plugin/src/containers/IntegrationSettings/IntegrationSettings.tsx b/grafana-plugin/src/containers/IntegrationSettings/IntegrationSettings.tsx index f6652400..f279fd36 100644 --- a/grafana-plugin/src/containers/IntegrationSettings/IntegrationSettings.tsx +++ b/grafana-plugin/src/containers/IntegrationSettings/IntegrationSettings.tsx @@ -54,11 +54,6 @@ const IntegrationSettings = observer((props: IntegrationSettingsProps) => { alertReceiveChannelStore.updateItem(id); }, []); - useEffect(() => { - setActiveTab(startTab || IntegrationSettingsTab.Templates); - LocationHelper.update({ tab: startTab || IntegrationSettingsTab.Templates }, 'partial'); - }, [startTab]); - const integration = alertReceiveChannelStore.getIntegration(alertReceiveChannel); const [expanded, _setExpanded] = useState(false); diff --git a/grafana-plugin/src/pages/integrations/Integrations.tsx b/grafana-plugin/src/pages/integrations/Integrations.tsx index e100ad16..b7b30347 100644 --- a/grafana-plugin/src/pages/integrations/Integrations.tsx +++ b/grafana-plugin/src/pages/integrations/Integrations.tsx @@ -51,20 +51,23 @@ class Integrations extends React.Component errorData: initErrorDataState(), }; - alertReceiveChanneltoPoll: { [key: string]: number } = {}; - alertReceiveChannelTimerId: ReturnType; + private alertReceiveChanneltoPoll: { [key: string]: number } = {}; + private alertReceiveChannelTimerId: ReturnType; async componentDidMount() { - this.update().then(this.parseQueryParams); + this.update().then(() => this.parseQueryParams(true)); } - setSelectedAlertReceiveChannel = (alertReceiveChannelId: AlertReceiveChannel['id']) => { + setSelectedAlertReceiveChannel = (alertReceiveChannelId: AlertReceiveChannel['id'], shouldRedirect = false) => { const { store, history } = this.props; store.selectedAlertReceiveChannel = alertReceiveChannelId; - history.push(`${PLUGIN_ROOT}/integrations/${alertReceiveChannelId || ''}`); + + if (shouldRedirect) { + history.push(`${PLUGIN_ROOT}/integrations/${alertReceiveChannelId || ''}`); + } }; - parseQueryParams = async () => { + parseQueryParams = async (isMounting = false) => { this.setState({ errorData: initErrorDataState() }); // reset wrong team error to false on query parse // reset wrong team error to false const { @@ -103,7 +106,7 @@ class Integrations extends React.Component } if (selectedAlertReceiveChannel) { - this.setSelectedAlertReceiveChannel(selectedAlertReceiveChannel); + this.setSelectedAlertReceiveChannel(selectedAlertReceiveChannel, isMounting); } }; @@ -112,15 +115,6 @@ class Integrations extends React.Component return store.alertReceiveChannelStore.updateItems(); }; - componentDidUpdate(prevProps: IntegrationsProps) { - if (this.props.match.params.id !== prevProps.match.params.id) { - this.parseQueryParams(); - } - if (this.props.query.tab !== prevProps.query.tab) { - this.parseQueryParams(); - } - } - componentWillUnmount() { clearInterval(this.alertReceiveChannelTimerId); } @@ -201,6 +195,8 @@ class Integrations extends React.Component alertReceiveChannelToShowSettings: store.selectedAlertReceiveChannel, integrationSettingsTab, }); + + LocationHelper.update({ tab: integrationSettingsTab }, 'partial'); }} /> @@ -268,7 +264,7 @@ class Integrations extends React.Component .then(async (alertReceiveChannel: AlertReceiveChannel) => { await store.alertReceiveChannelStore.updateItems(); - this.setSelectedAlertReceiveChannel(alertReceiveChannel.id); + this.setSelectedAlertReceiveChannel(alertReceiveChannel.id, true); this.setState({ alertReceiveChannelToShowSettings: alertReceiveChannel.id, @@ -315,7 +311,7 @@ class Integrations extends React.Component if (alertReceiveChannelId === store.selectedAlertReceiveChannel) { const searchResult = alertReceiveChannelStore.getSearchResult(); - this.setSelectedAlertReceiveChannel(searchResult && searchResult[0]?.id); + this.setSelectedAlertReceiveChannel(searchResult && searchResult[0]?.id, true); } }); }; @@ -345,7 +341,7 @@ class Integrations extends React.Component }; handleAlertReceiveChannelSelect = (id: AlertReceiveChannel['id']) => { - this.setSelectedAlertReceiveChannel(id); + this.setSelectedAlertReceiveChannel(id, true); }; }