Dashboard schema: Review and mature refresh property (#62104)

* Review and mature refresh property

* Update type

* Update report
This commit is contained in:
Dominik Prokop 2023-01-26 01:45:12 -08:00 committed by GitHub
parent 1423f15b0d
commit b9a1d8e5f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 13 additions and 15 deletions

View File

@ -3615,15 +3615,14 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Unexpected any. Specify a different type.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"],
[0, 0, 0, "Do not use any type assertions.", "29"],
[0, 0, 0, "Do not use any type assertions.", "28"],
[0, 0, 0, "Unexpected any. Specify a different type.", "29"],
[0, 0, 0, "Unexpected any. Specify a different type.", "30"],
[0, 0, 0, "Unexpected any. Specify a different type.", "31"],
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"],
[0, 0, 0, "Unexpected any. Specify a different type.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"],
[0, 0, 0, "Unexpected any. Specify a different type.", "36"]
[0, 0, 0, "Unexpected any. Specify a different type.", "35"]
],
"public/app/features/dashboard/state/PanelModel.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],

View File

@ -28,7 +28,7 @@ title: Dashboard kind
| `links` | [DashboardLink](#dashboardlink)[] | No | TODO docs |
| `liveNow` | boolean | No | TODO docs |
| `panels` | [object](#panels)[] | No | |
| `refresh` | | No | TODO docs |
| `refresh` | | No | Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". |
| `snapshot` | [Snapshot](#snapshot) | No | TODO docs |
| `tags` | string[] | No | Tags associated with dashboard. |
| `templating` | [object](#templating) | No | TODO docs |

View File

@ -63,8 +63,8 @@ lineage: seqs: [
// TODO docs
weekStart?: string @grafanamaturity(NeedsExpertReview)
// TODO docs
refresh?: string | false @grafanamaturity(NeedsExpertReview)
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
refresh?: string | false
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
// TODO this is the existing schema numbering system. It will be replaced by Thema's themaVersion

View File

@ -670,7 +670,7 @@ export interface Dashboard {
liveNow?: boolean;
panels?: Array<(Panel | RowPanel | GraphPanel | HeatmapPanel)>;
/**
* TODO docs
* Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
*/
refresh?: (string | false);
/**

View File

@ -240,7 +240,7 @@ type Dashboard struct {
LiveNow *bool `json:"liveNow,omitempty"`
Panels *[]interface{} `json:"panels,omitempty"`
// TODO docs
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
Refresh *interface{} `json:"refresh,omitempty"`
// Version of the current dashboard data

View File

@ -283,7 +283,7 @@
0,
0
],
"grafanaMaturityCount": 141,
"grafanaMaturityCount": 140,
"lineageIsGroup": false,
"links": {
"docs": "https://grafana.com/docs/grafana/next/developers/kinds/core/dashboard/schema-reference",

View File

@ -8,7 +8,6 @@ import { hasChanges, ignoreChanges } from './DashboardPrompt';
function getDefaultDashboardModel() {
return createDashboardModelFixture({
refresh: false,
panels: [
createPanelJSONFixture({
id: 1,
@ -56,7 +55,7 @@ describe('DashboardPrompt', () => {
it('Should ignore a lot of changes', () => {
const { original, dash } = getTestContext();
dash.time = { from: '1h' };
dash.refresh = true;
dash.refresh = '30s';
dash.schemaVersion = 10;
expect(hasChanges(dash, original)).toBe(false);
});

View File

@ -178,7 +178,7 @@ function cleanDashboardFromIgnoredChanges(dashData: Dashboard) {
// ignore time and refresh
dash.time = 0;
dash.refresh = 0;
dash.refresh = '';
dash.schemaVersion = 0;
dash.timezone = 0;

View File

@ -86,7 +86,7 @@ export class DashboardModel implements TimeModel {
templating: { list: any[] };
private originalTemplating: any;
annotations: { list: AnnotationQuery[] };
refresh: any;
refresh: string;
snapshot: any;
schemaVersion: number;
version: number;
@ -145,7 +145,7 @@ export class DashboardModel implements TimeModel {
this.liveNow = Boolean(data.liveNow);
this.templating = this.ensureListExist(data.templating);
this.annotations = this.ensureListExist(data.annotations);
this.refresh = data.refresh;
this.refresh = data.refresh || '';
this.snapshot = data.snapshot;
this.schemaVersion = data.schemaVersion ?? 0;
this.fiscalYearStartMonth = data.fiscalYearStartMonth ?? 0;