From c0d212d3ae92bfc293232a1203256c46e6d2dd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Mon, 5 May 2025 13:39:04 +0200 Subject: [PATCH] Feat: add option to show data source name (#2007) Original [PR](https://github.com/grafana/grafana-zabbix/pull/2003) Fixes #1766 --------- Co-authored-by: olaf --- .changeset/happy-trainers-sniff.md | 5 +++++ devenv/dashboards/zabbix_datasource_features.json | 2 ++ src/panel-triggers/components/AlertList/AlertCard.tsx | 3 +-- src/panel-triggers/migrations.ts | 1 + src/panel-triggers/module.tsx | 6 ++++++ src/panel-triggers/types.ts | 2 ++ 6 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/happy-trainers-sniff.md diff --git a/.changeset/happy-trainers-sniff.md b/.changeset/happy-trainers-sniff.md new file mode 100644 index 0000000..3bbb904 --- /dev/null +++ b/.changeset/happy-trainers-sniff.md @@ -0,0 +1,5 @@ +--- +'grafana-zabbix': minor +--- + +Problems Panel: Add option to show data source name diff --git a/devenv/dashboards/zabbix_datasource_features.json b/devenv/dashboards/zabbix_datasource_features.json index 3b243d7..e3bd80b 100644 --- a/devenv/dashboards/zabbix_datasource_features.json +++ b/devenv/dashboards/zabbix_datasource_features.json @@ -37,6 +37,7 @@ "uid": "PCAF1C06DCF802728" }, "descriptionAtNewLine": false, + "showDatasourceName": false, "descriptionField": true, "fontSize": "100%", "gridPos": { @@ -64,6 +65,7 @@ "allowDangerousHTML": false, "customLastChangeFormat": false, "descriptionAtNewLine": false, + "showDatasourceName": false, "descriptionField": true, "fontSize": "100%", "highlightBackground": false, diff --git a/src/panel-triggers/components/AlertList/AlertCard.tsx b/src/panel-triggers/components/AlertList/AlertCard.tsx index 3f6e5f1..c3573b6 100644 --- a/src/panel-triggers/components/AlertList/AlertCard.tsx +++ b/src/panel-triggers/components/AlertList/AlertCard.tsx @@ -36,7 +36,6 @@ export default class AlertCard extends PureComponent { render() { const { problem, panelOptions } = this.props; - const showDatasourceName = panelOptions.targets && panelOptions.targets.length > 1; const cardClass = cx('alert-rule-item', 'zbx-trigger-card', { 'zbx-trigger-highlighted': panelOptions.highlightBackground, }); @@ -153,7 +152,7 @@ export default class AlertCard extends PureComponent { - {showDatasourceName && ( + {panelOptions.showDatasourceName && (
diff --git a/src/panel-triggers/migrations.ts b/src/panel-triggers/migrations.ts index 9a6a185..939b331 100644 --- a/src/panel-triggers/migrations.ts +++ b/src/panel-triggers/migrations.ts @@ -205,6 +205,7 @@ export const problemsPanelMigrationHandler = (panel: PanelModel(ProblemsPanel) defaultValue: defaultPanelOptions.descriptionAtNewLine, showIf: (options) => options.layout === 'list', category: ['Fields'], + }) + .addBooleanSwitch({ + path: 'showDatasourceName', + name: 'Datasource name', + defaultValue: defaultPanelOptions.showDatasourceName, + category: ['Fields'], }); }); diff --git a/src/panel-triggers/types.ts b/src/panel-triggers/types.ts index c8620d9..c1ee546 100644 --- a/src/panel-triggers/types.ts +++ b/src/panel-triggers/types.ts @@ -19,6 +19,7 @@ export interface ProblemsPanelOptions { opdataField?: boolean; descriptionField?: boolean; descriptionAtNewLine?: boolean; + showDatasourceName?: boolean; // Options hostsInMaintenance?: boolean; showTriggers?: 'all triggers' | 'unacknowledged' | 'acknowledged'; @@ -70,6 +71,7 @@ export const defaultPanelOptions: Partial = { opdataField: false, descriptionField: true, descriptionAtNewLine: false, + showDatasourceName: false, // Options sortProblems: 'lastchange', limit: undefined,