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.", "25"],
[0, 0, 0, "Unexpected any. Specify a different type.", "26"], [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.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"], [0, 0, 0, "Do not use any type assertions.", "28"],
[0, 0, 0, "Do not use any type assertions.", "29"], [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.", "30"],
[0, 0, 0, "Unexpected any. Specify a different type.", "31"], [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.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"], [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.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"], [0, 0, 0, "Unexpected any. Specify a different type.", "35"]
[0, 0, 0, "Unexpected any. Specify a different type.", "36"]
], ],
"public/app/features/dashboard/state/PanelModel.test.ts:5381": [ "public/app/features/dashboard/state/PanelModel.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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 | | `links` | [DashboardLink](#dashboardlink)[] | No | TODO docs |
| `liveNow` | boolean | No | TODO docs | | `liveNow` | boolean | No | TODO docs |
| `panels` | [object](#panels)[] | No | | | `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 | | `snapshot` | [Snapshot](#snapshot) | No | TODO docs |
| `tags` | string[] | No | Tags associated with dashboard. | | `tags` | string[] | No | Tags associated with dashboard. |
| `templating` | [object](#templating) | No | TODO docs | | `templating` | [object](#templating) | No | TODO docs |

View File

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

View File

@ -240,7 +240,7 @@ type Dashboard struct {
LiveNow *bool `json:"liveNow,omitempty"` LiveNow *bool `json:"liveNow,omitempty"`
Panels *[]interface{} `json:"panels,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"` Refresh *interface{} `json:"refresh,omitempty"`
// Version of the current dashboard data // Version of the current dashboard data

View File

@ -283,7 +283,7 @@
0, 0,
0 0
], ],
"grafanaMaturityCount": 141, "grafanaMaturityCount": 140,
"lineageIsGroup": false, "lineageIsGroup": false,
"links": { "links": {
"docs": "https://grafana.com/docs/grafana/next/developers/kinds/core/dashboard/schema-reference", "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() { function getDefaultDashboardModel() {
return createDashboardModelFixture({ return createDashboardModelFixture({
refresh: false,
panels: [ panels: [
createPanelJSONFixture({ createPanelJSONFixture({
id: 1, id: 1,
@ -56,7 +55,7 @@ describe('DashboardPrompt', () => {
it('Should ignore a lot of changes', () => { it('Should ignore a lot of changes', () => {
const { original, dash } = getTestContext(); const { original, dash } = getTestContext();
dash.time = { from: '1h' }; dash.time = { from: '1h' };
dash.refresh = true; dash.refresh = '30s';
dash.schemaVersion = 10; dash.schemaVersion = 10;
expect(hasChanges(dash, original)).toBe(false); expect(hasChanges(dash, original)).toBe(false);
}); });

View File

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

View File

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