grafana/public/app/features/dashboard/state
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
..
actions.ts Dashboard Settings: Fix TimeZone dropdown doesn't change the timezone (#35680) 2021-06-16 08:31:16 +02:00
analyticsProcessor.ts Queries: Extract queries from dashboard (#29349) 2020-11-26 18:12:02 +01:00
DashboardMigrator.test.ts ValueMappings: Improve singlestat value mappings migration (#35578) 2021-06-14 13:47:34 +02:00
DashboardMigrator.ts Dashboard: protect against missing overrides section (#35577) 2021-06-17 08:33:36 +02:00
DashboardModel.repeat.test.ts Variables: Removes the never refresh option (#33533) 2021-04-30 11:17:35 +02:00
DashboardModel.test.ts Dashboard: Fix Editing a panel with auto-refresh enabled auto-refresh in the edit screen (#34128) 2021-05-18 10:20:11 +02:00
DashboardModel.ts 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
getPanelOptionsWithDefaults.test.ts Color: Fixes issue where colors where reset to gray when switch panels (#31611) 2021-03-04 08:04:45 +01:00
getPanelOptionsWithDefaults.ts Stat: improve color mode migration from singlestat panels (#35538) 2021-06-11 18:03:30 +02:00
index.ts Moved dashboard state components to state folder 2019-01-31 08:56:17 +01:00
initDashboard.test.ts ChangeTracker: Unified unsaved changes handling with library panels (#34989) 2021-06-02 12:24:19 +02:00
initDashboard.ts Chore: Remove endpoints that contain the slug field (#35104) 2021-06-03 16:20:13 +03:00
PanelModel.test.ts Dashboard: Fix Table view when editing causes the panel data to not update (#34998) 2021-06-01 13:52:08 +02:00
PanelModel.ts Dashboard: Fix Table view when editing causes the panel data to not update (#34998) 2021-06-01 13:52:08 +02:00
reducers.test.ts Eslint: no-duplicate-imports rule (bump grafana-eslint-config) (#30989) 2021-02-11 13:45:25 +01:00
reducers.ts Routing NG: Replace Angular routing with react-router (#31463) 2021-03-10 18:03:36 +01:00
selectors.ts PanelEdit: Fixed timing and state related issues (#22131) 2020-02-13 16:06:45 +01:00