grafana/public
Josh Myers eb7dd8e377
Dashboard: protect against missing overrides section (#35577)
* Protect against missing overrides section

We are using grafonnet-lib to generate dashboards. These dashboards do
not contain any `override` keys in `fieldConfig` by default and that is
causing this DashboardMigrator script to blow up when trying to import
the dashboards, see [1]. In Grafana v7, an empty overrides is
automatically added but using grafonnet-lib, it isn't possible to set an
empty overrides attribute e.g. [2] requires matcher/properties to be
set. Setting to null ends up giving me [3], which causes the panel to
not be displayed.

[1]
```
initDashboard.ts:137 TypeError: t.overrides is not iterable
    at v.w (DashboardMigrator.ts:960)
    at v.updateSchema (DashboardMigrator.ts:672)
    at D.updateSchema (DashboardModel.ts:993)
    at new D (DashboardModel.ts:156)
    at initDashboard.ts:134
```

[2]
https://github.com/grafana/grafonnet-lib/blob/master/grafonnet/stat_panel.libsonnet#L150-L164

[3]
```
"fieldConfig": {
   "defaults": {
      "links": [ ],
      "mappings": [ ],
      "thresholds": {
         "mode": "absolute",
         "steps": [
            {
               "color": "red",
               "value": 0
            },
            {
               "color": "orange",
               "value": 1
            },
            {
               "color": "green",
               "value": 3
            }
         ]
      },
      "unit": "none"
   },
   "overrides": [
      { }
   ]
},
```

* Update public/app/features/dashboard/state/DashboardMigrator.ts

Co-authored-by: Marcus Andersson <systemvetaren@gmail.com>
2021-06-17 08:33:36 +02:00
..
app Dashboard: protect against missing overrides section (#35577) 2021-06-17 08:33:36 +02:00
dashboards Prettier: Upgrade to 2 (#30387) 2021-01-20 07:59:48 +01:00
emails Alerting: update email template (#34205) 2021-05-19 18:58:31 +02:00
fonts Security: Update default CSP template and fix firefox CSP issues (#34836) 2021-05-28 17:01:10 +02:00
img Add custom icons for layout options (#34890) 2021-05-31 10:38:39 +03:00
lib AzureMonitor: Kusto language support (#33528) 2021-05-11 16:48:59 +02:00
sass Chore: Improve the mobile view of the login page (#32962) 2021-06-16 10:47:12 +02:00
test Chore: Update typescript to v4.2.4 (#33297) 2021-04-28 15:40:01 +03:00
testdata Histogram: Adds histogram test dashboard & test data (#34821) 2021-05-27 17:27:29 +02:00
vendor Decimals: Big Improvements to auto decimals and fixes to auto decimals bug found in 7.4-beta1 (#30519) 2021-01-22 16:37:56 +01:00
views CSP: Set nonce attribute on Webpack injected bundles (#33298) 2021-04-26 11:38:24 +02:00
robots.txt add support for robots.txt file 2015-06-15 19:02:38 -04:00