From c7c9412a14cc4f236d8a80171e6b7d55f6aae9cb Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 18 Apr 2022 16:19:57 +0300 Subject: [PATCH] Fix problems list panel error in new Grafana version --- src/panel-triggers/components/AlertList/AlertCard.tsx | 11 +++++++++-- src/panel-triggers/components/AlertList/AlertList.tsx | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/panel-triggers/components/AlertList/AlertCard.tsx b/src/panel-triggers/components/AlertList/AlertCard.tsx index 532c7ef..8d976f2 100644 --- a/src/panel-triggers/components/AlertList/AlertCard.tsx +++ b/src/panel-triggers/components/AlertList/AlertCard.tsx @@ -12,6 +12,7 @@ import { ProblemDTO, ZBXTag } from '../../../datasource-zabbix/types'; import { ModalController } from '../../../components'; import { DataSourceRef } from '@grafana/data'; import { Tooltip } from '@grafana/ui'; +import { getDataSourceSrv } from '@grafana/runtime'; interface AlertCardProps { problem: ProblemDTO; @@ -48,6 +49,12 @@ export default class AlertCard extends PureComponent { const lastchange = formatLastChange(problem.timestamp, panelOptions.customLastChangeFormat && panelOptions.lastChangeFormat); const age = moment.unix(problem.timestamp).fromNow(true); + let dsName: string = (problem.datasource as string); + if ((problem.datasource as DataSourceRef)?.uid) { + const dsInstance = getDataSourceSrv().getInstanceSettings((problem.datasource as DataSourceRef).uid); + dsName = dsInstance.name; + } + let newProblem = false; if (panelOptions.highlightNewerThan) { newProblem = isNewProblem(problem, panelOptions.highlightNewerThan); @@ -87,7 +94,7 @@ export default class AlertCard extends PureComponent { @@ -125,7 +132,7 @@ export default class AlertCard extends PureComponent {
- {problem.datasource} + {dsName}
)} diff --git a/src/panel-triggers/components/AlertList/AlertList.tsx b/src/panel-triggers/components/AlertList/AlertList.tsx index 0f50de5..f835da1 100644 --- a/src/panel-triggers/components/AlertList/AlertList.tsx +++ b/src/panel-triggers/components/AlertList/AlertList.tsx @@ -4,6 +4,7 @@ import { ProblemsPanelOptions, GFTimeRange } from '../../types'; import { AckProblemData } from '../AckModal'; import AlertCard from './AlertCard'; import { ProblemDTO, ZBXTag } from '../../../datasource-zabbix/types'; +import { DataSourceRef } from '@grafana/data'; export interface AlertListProps { problems: ProblemDTO[]; @@ -67,9 +68,9 @@ export default class AlertList extends PureComponent
    - {currentProblems.map(problem => + {currentProblems.map((problem, index) =>