grafana/public/app
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
..
angular Angular cleanup: Move directives (#35330) 2021-06-08 08:28:56 +02:00
core grafana/ui: Add DatePicker (#35742) 2021-06-16 15:57:12 +03:00
features Dashboard: protect against missing overrides section (#35577) 2021-06-17 08:33:36 +02:00
partials Chore: Migrates remaining Angular modals to React (#33476) 2021-04-28 15:22:28 +02:00
plugins 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
routes Chore: Remove endpoints that contain the slug field (#35104) 2021-06-03 16:20:13 +03:00
store Chore: remove redux-logger (#34220) 2021-05-17 16:43:40 +02:00
types 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
app.ts Login: Fixes Unauthorized message showing when on login page or snapshot page (#35311) 2021-06-07 11:42:49 +02:00
AppWrapper.tsx AppPlugins: Expose react-router to apps (#33775) 2021-05-19 19:10:21 +02:00
dev.ts React: Add why-did-you-render dev extension to better see what components re-render and why (in console) (#23455) 2020-04-09 19:44:05 +02:00
index.ts Grafana-UI: Switch CodeEditor to UMD @monao-editor/react (#33204) 2021-04-27 17:34:56 +01:00