grafana/public/app/features/dashboard
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
..
components Events: Migrate old timeRangeUpdate event to new event system to get rid of console.log warning (#35767) 2021-06-16 15:44:50 +02:00
containers Events: Migrate old timeRangeUpdate event to new event system to get rid of console.log warning (#35767) 2021-06-16 15:44:50 +02:00
dashgrid Dashboard: Fix changes doesn't reflect after changing panel sizes in inspect JSON and click on apply (#35276) 2021-06-15 14:12:32 +02:00
services Dashboard: handle the case where refresh_intervals could be null (#35511) 2021-06-11 16:20:18 +01:00
state Dashboard: protect against missing overrides section (#35577) 2021-06-17 08:33:36 +02:00
utils Library panels: Normalize feature name as "Library panels" (#33540) 2021-05-04 09:00:44 +01:00
index.ts Routing NG: Replace Angular routing with react-router (#31463) 2021-03-10 18:03:36 +01:00