diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dd12f8e..06502e4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix issue with helm chart when specifying `broker.type=rabbitmq` where Redis environment variables were not longer being injected @joeyorlando ([#2927](https://github.com/grafana/oncall/pull/2927)) +- Fixed NPE when migrating legacy Grafana Alerting integrations + ([#2908](https://github.com/grafana/oncall/issues/2908)) ## v1.3.29 (2023-08-29) diff --git a/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx b/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx index 580076c2..d574f504 100644 --- a/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx +++ b/grafana-plugin/src/containers/IntegrationForm/IntegrationForm.tsx @@ -93,7 +93,7 @@ const IntegrationForm = observer((props: IntegrationFormProps) => { const extraGFormProps: { customFieldSectionRenderer?: React.FC } = {}; - if (selectedOption && IntegrationHelper.isGrafanaAlerting(selectedOption.value)) { + if (selectedOption && IntegrationHelper.isSpecificIntegration(selectedOption.value, 'grafana_alerting')) { extraGFormProps.customFieldSectionRenderer = CustomFieldSectionRenderer; } @@ -205,7 +205,7 @@ const IntegrationForm = observer((props: IntegrationFormProps) => { return; } - if (!IntegrationHelper.isGrafanaAlerting(selectedOption.value)) { + if (!IntegrationHelper.isSpecificIntegration(selectedOption.value, 'grafana_alerting')) { return pushHistory(response.id); } diff --git a/grafana-plugin/src/pages/integration/Integration.helper.ts b/grafana-plugin/src/pages/integration/Integration.helper.ts index f4254c4b..b8c3080b 100644 --- a/grafana-plugin/src/pages/integration/Integration.helper.ts +++ b/grafana-plugin/src/pages/integration/Integration.helper.ts @@ -14,16 +14,16 @@ import { AppFeature } from 'state/features'; import { MAX_CHARACTERS_COUNT, TEXTAREA_ROWS_COUNT } from './IntegrationCommon.config'; const IntegrationHelper = { - isGrafanaAlerting: (alertReceiveChannel: AlertReceiveChannel | string) => { + isSpecificIntegration: (alertReceiveChannel: AlertReceiveChannel | string, name: string) => { if (!alertReceiveChannel) { return false; } if (typeof alertReceiveChannel === 'string') { - return alertReceiveChannel === 'grafana_alerting'; + return name === alertReceiveChannel; } - return alertReceiveChannel.integration === 'grafana_alerting'; + return name === alertReceiveChannel.integration; }, getFilteredTemplate: (template: string, isTextArea: boolean): string => { diff --git a/grafana-plugin/src/pages/integration/Integration.tsx b/grafana-plugin/src/pages/integration/Integration.tsx index afe9128b..01aa5c60 100644 --- a/grafana-plugin/src/pages/integration/Integration.tsx +++ b/grafana-plugin/src/pages/integration/Integration.tsx @@ -325,7 +325,7 @@ class Integration extends React.Component { } renderContactPointsWarningMaybe(alertReceiveChannel: AlertReceiveChannel) { - if (IntegrationHelper.isGrafanaAlerting(alertReceiveChannel)) { + if (IntegrationHelper.isSpecificIntegration(alertReceiveChannel, 'grafana_alerting')) { return (
{ const alertReceiveChannel = alertReceiveChannelStore.items[id]; const contactPoints = alertReceiveChannelStore.connectedContactPoints[id]; + const isAlerting = IntegrationHelper.isSpecificIntegration(alertReceiveChannel, 'grafana_alerting'); + const isLegacyAlerting = IntegrationHelper.isSpecificIntegration(alertReceiveChannel, 'legacy_grafana_alerting'); + return [ - IntegrationHelper.isGrafanaAlerting(alertReceiveChannel) && { - isHidden: contactPoints === null || contactPoints === undefined, + (isAlerting || isLegacyAlerting) && { + isHidden: isLegacyAlerting || contactPoints === null || contactPoints === undefined, isCollapsible: false, customIcon: 'grafana', canHoverIcon: false, @@ -709,7 +712,7 @@ class Integration extends React.Component { async loadExtraData(id: AlertReceiveChannel['id']) { const { alertReceiveChannelStore } = this.props.store; - if (IntegrationHelper.isGrafanaAlerting(alertReceiveChannelStore.items[id])) { + if (IntegrationHelper.isSpecificIntegration(alertReceiveChannelStore.items[id], 'grafana_alerting')) { // this will be delayed and not awaitable so that we don't delay the whole page load return await alertReceiveChannelStore.updateConnectedContactPoints(id); }