From 0d7259c14cd57bcce358f677d856a62c12b85563 Mon Sep 17 00:00:00 2001 From: Giuseppe Guerra Date: Wed, 5 Mar 2025 14:35:53 +0100 Subject: [PATCH 1/2] Use new isLegacyPanel function --- detector/detector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detector/detector.go b/detector/detector.go index 55a5654..bddb3b4 100644 --- a/detector/detector.go +++ b/detector/detector.go @@ -275,7 +275,7 @@ func (d *Detector) checkPanel(dashboardDefinition *grafana.DashboardDefinition, var out []output.Detection // Check panel - if p.Type == pluginIDGraphOld || p.Type == pluginIDTableOld || (p.Type == pluginIDTable && dashboardDefinition.Dashboard.SchemaVersion < 24) { + if d.isLegacyPanel(p.Type, dashboardDefinition.Dashboard.SchemaVersion) { // Different warning on legacy panel that can be migrated to React automatically out = append(out, output.Detection{ DetectionType: output.DetectionTypeLegacyPanel, From 55297db14225e6a4b99ee7d072a3388127b8b750 Mon Sep 17 00:00:00 2001 From: Giuseppe Guerra Date: Wed, 5 Mar 2025 14:35:56 +0100 Subject: [PATCH 2/2] Fix tests --- detector/detector_test.go | 16 ++-- .../{worldmap.json => datatable.json} | 2 +- detector/testdata/dashboards/mixed.json | 2 +- detector/testdata/dashboards/multiple.json | 4 +- .../testdata/dashboards/rows-collapsed.json | 2 +- .../testdata/dashboards/rows-expanded.json | 2 +- detector/testdata/frontend-settings.json | 78 +++++++++++++++++ detector/testdata/plugins.json | 86 +++++++++++++++++++ 8 files changed, 178 insertions(+), 14 deletions(-) rename detector/testdata/dashboards/{worldmap.json => datatable.json} (97%) diff --git a/detector/detector_test.go b/detector/detector_test.go index d08f7b3..e2c297c 100644 --- a/detector/detector_test.go +++ b/detector/detector_test.go @@ -55,12 +55,12 @@ func TestDetector(t *testing.T) { }, { name: "angular panel", - file: "worldmap.json", + file: "datatable.json", expDetections: []expDetection{{ - pluginID: "grafana-worldmap-panel", + pluginID: "briangann-datatable-panel", detectionType: output.DetectionTypePanel, title: "Panel Title", - message: `Found angular panel "Panel Title" ("grafana-worldmap-panel")`, + message: `Found angular panel "Panel Title" ("briangann-datatable-panel")`, }}, }, { @@ -78,8 +78,8 @@ func TestDetector(t *testing.T) { file: "multiple.json", expDetections: []expDetection{ {pluginID: "akumuli-datasource", detectionType: output.DetectionTypeDatasource, title: "akumuli"}, - {pluginID: "grafana-worldmap-panel", detectionType: output.DetectionTypePanel, title: "worldmap + akumuli"}, - {pluginID: "akumuli-datasource", detectionType: output.DetectionTypeDatasource, title: "worldmap + akumuli"}, + {pluginID: "briangann-datatable-panel", detectionType: output.DetectionTypePanel, title: "datatable + akumuli"}, + {pluginID: "akumuli-datasource", detectionType: output.DetectionTypeDatasource, title: "datatable + akumuli"}, {pluginID: "graph", detectionType: output.DetectionTypeLegacyPanel, title: "graph-old"}, }, }, @@ -92,21 +92,21 @@ func TestDetector(t *testing.T) { name: "mix of angular and react", file: "mixed.json", expDetections: []expDetection{ - {pluginID: "grafana-worldmap-panel", detectionType: output.DetectionTypePanel, title: "angular"}, + {pluginID: "briangann-datatable-panel", detectionType: output.DetectionTypePanel, title: "angular"}, }, }, { name: "rows expanded", file: "rows-expanded.json", expDetections: []expDetection{ - {pluginID: "grafana-worldmap-panel", detectionType: output.DetectionTypePanel, title: "expanded"}, + {pluginID: "briangann-datatable-panel", detectionType: output.DetectionTypePanel, title: "expanded"}, }, }, { name: "rows collapsed", file: "rows-collapsed.json", expDetections: []expDetection{ - {pluginID: "grafana-worldmap-panel", detectionType: output.DetectionTypePanel, title: "collapsed"}, + {pluginID: "briangann-datatable-panel", detectionType: output.DetectionTypePanel, title: "collapsed"}, }, }, } { diff --git a/detector/testdata/dashboards/worldmap.json b/detector/testdata/dashboards/datatable.json similarity index 97% rename from detector/testdata/dashboards/worldmap.json rename to detector/testdata/dashboards/datatable.json index 3da7df7..b0e8bf7 100644 --- a/detector/testdata/dashboards/worldmap.json +++ b/detector/testdata/dashboards/datatable.json @@ -62,7 +62,7 @@ }, "thresholds": "0,10", "title": "Panel Title", - "type": "grafana-worldmap-panel", + "type": "briangann-datatable-panel", "unitPlural": "", "unitSingle": "", "valueName": "total" diff --git a/detector/testdata/dashboards/mixed.json b/detector/testdata/dashboards/mixed.json index 57734c2..a9df861 100644 --- a/detector/testdata/dashboards/mixed.json +++ b/detector/testdata/dashboards/mixed.json @@ -244,7 +244,7 @@ }, "thresholds": "0,10", "title": "angular", - "type": "grafana-worldmap-panel", + "type": "briangann-datatable-panel", "unitPlural": "", "unitSingle": "", "valueName": "total" diff --git a/detector/testdata/dashboards/multiple.json b/detector/testdata/dashboards/multiple.json index 280ebab..bf25342 100644 --- a/detector/testdata/dashboards/multiple.json +++ b/detector/testdata/dashboards/multiple.json @@ -153,8 +153,8 @@ "queryType": "geohash" }, "thresholds": "0,10", - "title": "worldmap + akumuli", - "type": "grafana-worldmap-panel", + "title": "datatable + akumuli", + "type": "briangann-datatable-panel", "unitPlural": "", "unitSingle": "", "valueName": "total" diff --git a/detector/testdata/dashboards/rows-collapsed.json b/detector/testdata/dashboards/rows-collapsed.json index 5935464..1b9ae5c 100644 --- a/detector/testdata/dashboards/rows-collapsed.json +++ b/detector/testdata/dashboards/rows-collapsed.json @@ -72,7 +72,7 @@ }, "thresholds": "0,10", "title": "collapsed", - "type": "grafana-worldmap-panel", + "type": "briangann-datatable-panel", "unitPlural": "", "unitSingle": "", "valueName": "total" diff --git a/detector/testdata/dashboards/rows-expanded.json b/detector/testdata/dashboards/rows-expanded.json index 1df4fe3..ded0dd3 100644 --- a/detector/testdata/dashboards/rows-expanded.json +++ b/detector/testdata/dashboards/rows-expanded.json @@ -75,7 +75,7 @@ }, "thresholds": "0,10", "title": "expanded", - "type": "grafana-worldmap-panel", + "type": "briangann-datatable-panel", "unitPlural": "", "unitSingle": "", "valueName": "total" diff --git a/detector/testdata/frontend-settings.json b/detector/testdata/frontend-settings.json index b56730f..f993016 100644 --- a/detector/testdata/frontend-settings.json +++ b/detector/testdata/frontend-settings.json @@ -3687,6 +3687,84 @@ "hideDeprecation": false } }, + "briangann-datatable-panel": { + "id": "briangann-datatable-panel", + "name": "Datatable Panel", + "info": { + "author": { + "name": "Brian Gann (bkgann@gmail.com)", + "url": "https://github.com/briangann" + }, + "description": "Datatable panel for Grafana", + "links": [ + { + "name": "Project site", + "url": "https://github.com/briangann/grafana-datatable-panel" + }, + { + "name": "MIT License", + "url": "https://github.com/briangann/grafana-datatable-panel/blob/master/LICENSE" + } + ], + "logos": { + "small": "public/plugins/briangann-datatable-panel/img/nav-dt.png", + "large": "public/plugins/briangann-datatable-panel/img/nav-dt.png" + }, + "build": {}, + "screenshots": [ + { + "name": "Showcase Paging", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-default-paging.png" + }, + { + "name": "Showcase Scrolling", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-scroll.png" + }, + { + "name": "Showcase Compact Numbered", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-compact-numbered.png" + }, + { + "name": "Options", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-options.png" + }, + { + "name": "Datatable Options", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-dt-options.png" + }, + { + "name": "Thresholding with Row Coloring", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-threshold-row.png" + }, + { + "name": "Thresholding with Cell Coloring", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-threshold-cell.png" + }, + { + "name": "Thresholding with Value Coloring", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-threshold-value.png" + } + ], + "version": "1.0.4", + "updated": "2023-09-12", + "keywords": [ + "table", + "panel" + ] + }, + "hideFromList": false, + "sort": 100, + "skipDataQuery": false, + "state": "", + "baseUrl": "public/plugins/briangann-datatable-panel", + "signature": "valid", + "module": "public/plugins/briangann-datatable-panel/module.js", + "angular": { + "detected": true, + "hideDeprecation": false + }, + "loadingStrategy": "fetch" + }, "candlestick": { "id": "candlestick", "name": "Candlestick", diff --git a/detector/testdata/plugins.json b/detector/testdata/plugins.json index 0651239..96ca6dc 100644 --- a/detector/testdata/plugins.json +++ b/detector/testdata/plugins.json @@ -2499,5 +2499,91 @@ "signatureOrg": "", "angularDetected": false, "apiVersion": "" + }, + { + "name": "Datatable Panel", + "type": "panel", + "id": "briangann-datatable-panel", + "enabled": true, + "pinned": false, + "info": { + "author": { + "name": "Brian Gann (bkgann@gmail.com)", + "url": "https://github.com/briangann" + }, + "description": "Datatable panel for Grafana", + "links": [ + { + "name": "Project site", + "url": "https://github.com/briangann/grafana-datatable-panel" + }, + { + "name": "MIT License", + "url": "https://github.com/briangann/grafana-datatable-panel/blob/master/LICENSE" + } + ], + "logos": { + "small": "public/plugins/briangann-datatable-panel/img/nav-dt.png", + "large": "public/plugins/briangann-datatable-panel/img/nav-dt.png" + }, + "build": {}, + "screenshots": [ + { + "name": "Showcase Paging", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-default-paging.png" + }, + { + "name": "Showcase Scrolling", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-scroll.png" + }, + { + "name": "Showcase Compact Numbered", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-compact-numbered.png" + }, + { + "name": "Options", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-options.png" + }, + { + "name": "Datatable Options", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-dt-options.png" + }, + { + "name": "Thresholding with Row Coloring", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-threshold-row.png" + }, + { + "name": "Thresholding with Cell Coloring", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-threshold-cell.png" + }, + { + "name": "Thresholding with Value Coloring", + "path": "public/plugins/briangann-datatable-panel/screenshots/datatable-threshold-value.png" + } + ], + "version": "1.0.4", + "updated": "2023-09-12", + "keywords": [ + "table", + "panel" + ] + }, + "dependencies": { + "grafanaDependency": "\u003e=8.0.7", + "grafanaVersion": "*", + "plugins": [], + "extensions": { + "exposedComponents": [] + } + }, + "latestVersion": "", + "hasUpdate": false, + "defaultNavUrl": "/plugins/briangann-datatable-panel/", + "category": "", + "state": "", + "signature": "valid", + "signatureType": "community", + "signatureOrg": "Brian Gann", + "angularDetected": true } ]