mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Schema: Clean up / correct panel schema (#76346)
* Schema: Clean up / correct panel schema * fixes
This commit is contained in:
@@ -71,13 +71,13 @@ extraFields is reserved for any fields that are pulled from the API server metad
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|------------------------|---------------------------------------------|----------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `editable` | boolean | **Yes** | `true` | Whether a dashboard is editable or not. |
|
||||
| `graphTooltip` | integer | **Yes** | `0` | 0 for no shared crosshair or tooltip (default).<br/>1 for shared crosshair.<br/>2 for shared crosshair AND shared tooltip.<br/>Possible values are: `0`, `1`, `2`. |
|
||||
| `schemaVersion` | uint16 | **Yes** | `36` | Version of the JSON schema, incremented each time a Grafana update brings<br/>changes to said schema. |
|
||||
| `annotations` | [AnnotationContainer](#annotationcontainer) | No | | Contains the list of annotations that are associated with the dashboard.<br/>Annotations are used to overlay event markers and overlay event tags on graphs.<br/>Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.<br/>See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/ |
|
||||
| `description` | string | No | | Description of dashboard. |
|
||||
| `editable` | boolean | No | `true` | Whether a dashboard is editable or not. |
|
||||
| `fiscalYearStartMonth` | integer | No | `0` | The month that the fiscal year starts on. 0 = January, 11 = December<br/>Constraint: `>=0 & <12`. |
|
||||
| `gnetId` | string | No | | ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal |
|
||||
| `graphTooltip` | integer | No | `0` | 0 for no shared crosshair or tooltip (default).<br/>1 for shared crosshair.<br/>2 for shared crosshair AND shared tooltip.<br/>Possible values are: `0`, `1`, `2`. |
|
||||
| `id` | integer or null | No | | Unique numeric identifier for the dashboard.<br/>`id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. |
|
||||
| `links` | [DashboardLink](#dashboardlink)[] | No | | Links with references to other dashboards or external websites. |
|
||||
| `liveNow` | boolean | No | | When set to true, the dashboard will redraw panels at an interval matching the pixel width.<br/>This will keep data "moving left" regardless of the query refresh rate. This setting helps<br/>avoid dashboards presenting stale live data |
|
||||
@@ -191,9 +191,9 @@ Sensitive information stripped: queries (metric, template,annotation) and panel
|
||||
|
||||
### Panels
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|----------|-----------------------------------------------------------------------------------------------------------------------|----------|---------|-------------|
|
||||
| `object` | Possible types are: [Panel](#panel), [RowPanel](#rowpanel), [GraphPanel](#graphpanel), [HeatmapPanel](#heatmappanel). | | |
|
||||
| Property | Type | Required | Default | Description |
|
||||
|----------|-------------------------------------------------------------------------------------------------------------|----------|---------|-------------|
|
||||
| `object` | Possible types are: [](#), [RowPanel](#rowpanel), [GraphPanel](#graphpanel), [HeatmapPanel](#heatmappanel). | | |
|
||||
|
||||
### DataTransformerConfig
|
||||
|
||||
@@ -443,19 +443,37 @@ Library panels streamline reuse of panels across multiple dashboards.
|
||||
| `name` | string | **Yes** | | Library panel name |
|
||||
| `uid` | string | **Yes** | | Library panel uid |
|
||||
|
||||
### RowPanel
|
||||
|
||||
Row panel
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|--------------|---------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `collapsed` | boolean | **Yes** | `false` | Whether this row should be collapsed or not. |
|
||||
| `id` | uint32 | **Yes** | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
|
||||
| `panels` | [panels](#panels)[] | **Yes** | | List of panels in the row |
|
||||
| `type` | string | **Yes** | | The panel type<br/>Possible values are: `row`. |
|
||||
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
|
||||
| `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
|
||||
| `repeat` | string | No | | Name of template variable to repeat for. |
|
||||
| `title` | string | No | | Row title |
|
||||
|
||||
### Panels
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|----------|------------------------------------------------------------------------------------------------|----------|---------|-------------|
|
||||
| `object` | Possible types are: [Panel](#panel), [GraphPanel](#graphpanel), [HeatmapPanel](#heatmappanel). | | |
|
||||
|
||||
### Panel
|
||||
|
||||
Dashboard panels are the basic visualization building blocks.
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|--------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | **Yes** | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
|
||||
| `options` | [object](#options) | **Yes** | | It depends on the panel plugin. They are specified by the Options field in panel plugin schemas. |
|
||||
| `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | **Yes** | | List of transformations that are applied to the panel data before rendering.<br/>When there are multiple transformations, Grafana applies them in the order they are listed.<br/>Each transformation creates a result set that then passes on to the next transformation in the processing pipeline. |
|
||||
| `transparent` | boolean | **Yes** | `false` | Whether to display the panel without a background. |
|
||||
| `type` | string | **Yes** | | The panel plugin type id. This is used to find the plugin to display the panel.<br/>Constraint: `length >=1`. |
|
||||
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
|
||||
| `description` | string | No | | Panel description. |
|
||||
| `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | No | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
|
||||
| `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
|
||||
| `hideTimeOverride` | boolean | No | | Controls if the timeFrom or timeShift overrides are shown in the panel header |
|
||||
| `id` | uint32 | No | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
|
||||
@@ -464,6 +482,7 @@ Dashboard panels are the basic visualization building blocks.
|
||||
| `links` | [DashboardLink](#dashboardlink)[] | No | | Panel links. |
|
||||
| `maxDataPoints` | number | No | | The maximum number of data points that the panel queries are retrieving. |
|
||||
| `maxPerRow` | number | No | | Option for repeated panels that controls max items per row<br/>Only relevant for horizontally repeated panels |
|
||||
| `options` | [object](#options) | No | | It depends on the panel plugin. They are specified by the Options field in panel plugin schemas. |
|
||||
| `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
|
||||
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
|
||||
| `repeat` | string | No | | Name of template variable to repeat for. |
|
||||
@@ -472,6 +491,8 @@ Dashboard panels are the basic visualization building blocks.
|
||||
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||
| `title` | string | No | | Panel title. |
|
||||
| `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | No | | List of transformations that are applied to the panel data before rendering.<br/>When there are multiple transformations, Grafana applies them in the order they are listed.<br/>Each transformation creates a result set that then passes on to the next transformation in the processing pipeline. |
|
||||
| `transparent` | boolean | No | `false` | Whether to display the panel without a background. |
|
||||
|
||||
### FieldConfigSource
|
||||
|
||||
@@ -560,27 +581,6 @@ It depends on the panel plugin. They are specified by the Options field in panel
|
||||
| Property | Type | Required | Default | Description |
|
||||
|----------|------|----------|---------|-------------|
|
||||
|
||||
### RowPanel
|
||||
|
||||
Row panel
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|--------------|---------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `collapsed` | boolean | **Yes** | `false` | Whether this row should be collapsed or not. |
|
||||
| `id` | uint32 | **Yes** | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
|
||||
| `panels` | [panels](#panels)[] | **Yes** | | List of panels in the row |
|
||||
| `type` | string | **Yes** | | The panel type<br/>Possible values are: `row`. |
|
||||
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
|
||||
| `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
|
||||
| `repeat` | string | No | | Name of template variable to repeat for. |
|
||||
| `title` | string | No | | Row title |
|
||||
|
||||
### Panels
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|----------|------------------------------------------------------------------------------------------------|----------|---------|-------------|
|
||||
| `object` | Possible types are: [Panel](#panel), [GraphPanel](#graphpanel), [HeatmapPanel](#heatmappanel). | | |
|
||||
|
||||
### GraphPanel
|
||||
|
||||
Support for legacy graph panel.
|
||||
@@ -597,13 +597,10 @@ Dashboard panels are the basic visualization building blocks.
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|--------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | **Yes** | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
|
||||
| `options` | [options](#options) | **Yes** | | It depends on the panel plugin. They are specified by the Options field in panel plugin schemas. |
|
||||
| `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | **Yes** | | List of transformations that are applied to the panel data before rendering.<br/>When there are multiple transformations, Grafana applies them in the order they are listed.<br/>Each transformation creates a result set that then passes on to the next transformation in the processing pipeline. |
|
||||
| `transparent` | boolean | **Yes** | `false` | Whether to display the panel without a background. |
|
||||
| `type` | string | **Yes** | | The panel plugin type id. This is used to find the plugin to display the panel.<br/>Constraint: `length >=1`. |
|
||||
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
|
||||
| `description` | string | No | | Panel description. |
|
||||
| `fieldConfig` | [FieldConfigSource](#fieldconfigsource) | No | | The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.<br/>Each column within this structure is called a field. A field can represent a single time series or table column.<br/>Field options allow you to change how the data is displayed in your visualizations. |
|
||||
| `gridPos` | [GridPos](#gridpos) | No | | Position and dimensions of a panel in the grid |
|
||||
| `hideTimeOverride` | boolean | No | | Controls if the timeFrom or timeShift overrides are shown in the panel header |
|
||||
| `id` | uint32 | No | | Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally. |
|
||||
@@ -612,6 +609,7 @@ Dashboard panels are the basic visualization building blocks.
|
||||
| `links` | [DashboardLink](#dashboardlink)[] | No | | Panel links. |
|
||||
| `maxDataPoints` | number | No | | The maximum number of data points that the panel queries are retrieving. |
|
||||
| `maxPerRow` | number | No | | Option for repeated panels that controls max items per row<br/>Only relevant for horizontally repeated panels |
|
||||
| `options` | [options](#options) | No | | It depends on the panel plugin. They are specified by the Options field in panel plugin schemas. |
|
||||
| `pluginVersion` | string | No | | The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs. |
|
||||
| `repeatDirection` | string | No | `h` | Direction to repeat in if 'repeat' is set.<br/>`h` for horizontal, `v` for vertical.<br/>Possible values are: `h`, `v`. |
|
||||
| `repeat` | string | No | | Name of template variable to repeat for. |
|
||||
@@ -620,6 +618,8 @@ Dashboard panels are the basic visualization building blocks.
|
||||
| `timeFrom` | string | No | | Overrides the relative time range for individual panels,<br/>which causes them to be different than what is selected in<br/>the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different<br/>time periods or days on the same dashboard.<br/>The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),<br/>`now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||
| `timeShift` | string | No | | Overrides the time range for individual panels by shifting its start and end relative to the time picker.<br/>For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.<br/>Note: Panel time overrides have no effect when the dashboard’s time range is absolute.<br/>See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options |
|
||||
| `title` | string | No | | Panel title. |
|
||||
| `transformations` | [DataTransformerConfig](#datatransformerconfig)[] | No | | List of transformations that are applied to the panel data before rendering.<br/>When there are multiple transformations, Grafana applies them in the order they are listed.<br/>Each transformation creates a result set that then passes on to the next transformation in the processing pipeline. |
|
||||
| `transparent` | boolean | No | `false` | Whether to display the panel without a background. |
|
||||
|
||||
### Templating
|
||||
|
||||
|
@@ -42,11 +42,11 @@ lineage: schemas: [{
|
||||
timezone?: string | *"browser"
|
||||
|
||||
// Whether a dashboard is editable or not.
|
||||
editable: bool | *true
|
||||
editable?: bool | *true
|
||||
|
||||
// Configuration of dashboard cursor sync behavior.
|
||||
// Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).
|
||||
graphTooltip: #DashboardCursorSync
|
||||
graphTooltip?: #DashboardCursorSync
|
||||
|
||||
// Time range for dashboard.
|
||||
// Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}.
|
||||
@@ -515,7 +515,7 @@ lineage: schemas: [{
|
||||
description?: string
|
||||
|
||||
// Whether to display the panel without a background.
|
||||
transparent: bool | *false
|
||||
transparent?: bool | *false
|
||||
|
||||
// The datasource used in all targets.
|
||||
datasource?: #DataSourceRef
|
||||
@@ -543,7 +543,7 @@ lineage: schemas: [{
|
||||
// List of transformations that are applied to the panel data before rendering.
|
||||
// When there are multiple transformations, Grafana applies them in the order they are listed.
|
||||
// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
|
||||
transformations: [...#DataTransformerConfig]
|
||||
transformations?: [...#DataTransformerConfig]
|
||||
|
||||
// The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.
|
||||
// This value must be formatted as a number followed by a valid time
|
||||
@@ -574,10 +574,10 @@ lineage: schemas: [{
|
||||
libraryPanel?: #LibraryPanelRef
|
||||
|
||||
// It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
|
||||
options: {...} @grafanamaturity(NeedsExpertReview)
|
||||
options?: {...} @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
// Field options allow you to change how the data is displayed in your visualizations.
|
||||
fieldConfig: #FieldConfigSource
|
||||
fieldConfig?: #FieldConfigSource
|
||||
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|
||||
|
@@ -644,7 +644,7 @@ export interface Panel {
|
||||
/**
|
||||
* Field options allow you to change how the data is displayed in your visualizations.
|
||||
*/
|
||||
fieldConfig: FieldConfigSource;
|
||||
fieldConfig?: FieldConfigSource;
|
||||
/**
|
||||
* Grid position.
|
||||
*/
|
||||
@@ -684,7 +684,7 @@ export interface Panel {
|
||||
/**
|
||||
* It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
|
||||
*/
|
||||
options: Record<string, unknown>;
|
||||
options?: Record<string, unknown>;
|
||||
/**
|
||||
* The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
|
||||
*/
|
||||
@@ -733,11 +733,11 @@ export interface Panel {
|
||||
* When there are multiple transformations, Grafana applies them in the order they are listed.
|
||||
* Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
|
||||
*/
|
||||
transformations: Array<DataTransformerConfig>;
|
||||
transformations?: Array<DataTransformerConfig>;
|
||||
/**
|
||||
* Whether to display the panel without a background.
|
||||
*/
|
||||
transparent: boolean;
|
||||
transparent?: boolean;
|
||||
/**
|
||||
* The panel plugin type id. This is used to find the plugin to display the panel.
|
||||
*/
|
||||
@@ -991,7 +991,7 @@ export interface Dashboard {
|
||||
/**
|
||||
* Whether a dashboard is editable or not.
|
||||
*/
|
||||
editable: boolean;
|
||||
editable?: boolean;
|
||||
/**
|
||||
* The month that the fiscal year starts on. 0 = January, 11 = December
|
||||
*/
|
||||
@@ -1004,7 +1004,7 @@ export interface Dashboard {
|
||||
* Configuration of dashboard cursor sync behavior.
|
||||
* Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).
|
||||
*/
|
||||
graphTooltip: DashboardCursorSync;
|
||||
graphTooltip?: DashboardCursorSync;
|
||||
/**
|
||||
* Unique numeric identifier for the dashboard.
|
||||
* `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
|
||||
|
@@ -7,7 +7,7 @@ export type { CommonDataSourceRef as DataSourceRef };
|
||||
|
||||
export interface Panel<TOptions = Record<string, unknown>, TCustomFieldConfig = Record<string, unknown>>
|
||||
extends Omit<raw.Panel, 'fieldConfig'> {
|
||||
fieldConfig: FieldConfigSource<TCustomFieldConfig>;
|
||||
fieldConfig?: FieldConfigSource<TCustomFieldConfig>;
|
||||
}
|
||||
|
||||
export interface RowPanel extends Omit<raw.RowPanel, 'panels'> {
|
||||
|
@@ -529,7 +529,7 @@ type Panel struct {
|
||||
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|
||||
// Each column within this structure is called a field. A field can represent a single time series or table column.
|
||||
// Field options allow you to change how the data is displayed in your visualizations.
|
||||
FieldConfig FieldConfigSource `json:"fieldConfig"`
|
||||
FieldConfig *FieldConfigSource `json:"fieldConfig,omitempty"`
|
||||
|
||||
// Position and dimensions of a panel in the grid
|
||||
GridPos *GridPos `json:"gridPos,omitempty"`
|
||||
@@ -562,7 +562,7 @@ type Panel struct {
|
||||
MaxPerRow *float32 `json:"maxPerRow,omitempty"`
|
||||
|
||||
// It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
|
||||
Options map[string]any `json:"options"`
|
||||
Options map[string]any `json:"options,omitempty"`
|
||||
|
||||
// The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
|
||||
PluginVersion *string `json:"pluginVersion,omitempty"`
|
||||
@@ -602,10 +602,10 @@ type Panel struct {
|
||||
// List of transformations that are applied to the panel data before rendering.
|
||||
// When there are multiple transformations, Grafana applies them in the order they are listed.
|
||||
// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
|
||||
Transformations []DataTransformerConfig `json:"transformations"`
|
||||
Transformations []DataTransformerConfig `json:"transformations,omitempty"`
|
||||
|
||||
// Whether to display the panel without a background.
|
||||
Transparent bool `json:"transparent"`
|
||||
Transparent *bool `json:"transparent,omitempty"`
|
||||
|
||||
// The panel plugin type id. This is used to find the plugin to display the panel.
|
||||
Type string `json:"type"`
|
||||
@@ -734,7 +734,7 @@ type Spec struct {
|
||||
Description *string `json:"description,omitempty"`
|
||||
|
||||
// Whether a dashboard is editable or not.
|
||||
Editable bool `json:"editable"`
|
||||
Editable *bool `json:"editable,omitempty"`
|
||||
|
||||
// The month that the fiscal year starts on. 0 = January, 11 = December
|
||||
FiscalYearStartMonth *int `json:"fiscalYearStartMonth,omitempty"`
|
||||
@@ -745,7 +745,7 @@ type Spec struct {
|
||||
// 0 for no shared crosshair or tooltip (default).
|
||||
// 1 for shared crosshair.
|
||||
// 2 for shared crosshair AND shared tooltip.
|
||||
GraphTooltip CursorSync `json:"graphTooltip"`
|
||||
GraphTooltip *CursorSync `json:"graphTooltip,omitempty"`
|
||||
|
||||
// Unique numeric identifier for the dashboard.
|
||||
// `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
|
||||
|
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { PanelModel } from '../dashboard/state';
|
||||
import { createDashboardModelFixture, createPanelJSONFixture } from '../dashboard/state/__fixtures__/dashboardFixtures';
|
||||
import { createDashboardModelFixture, createPanelSaveModel } from '../dashboard/state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import { TestRuleResult } from './TestRuleResult';
|
||||
|
||||
@@ -22,7 +22,7 @@ jest.mock('@grafana/runtime', () => {
|
||||
const props: React.ComponentProps<typeof TestRuleResult> = {
|
||||
panel: new PanelModel({ id: 1 }),
|
||||
dashboard: createDashboardModelFixture({
|
||||
panels: [createPanelJSONFixture({ id: 1 })],
|
||||
panels: [createPanelSaveModel({ id: 1 })],
|
||||
}),
|
||||
};
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import {
|
||||
} from '@grafana/scenes';
|
||||
import { DashboardCursorSync, defaultDashboard, Panel, RowPanel, VariableType } from '@grafana/schema';
|
||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||
import { createPanelJSONFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
import { createPanelSaveModel } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
import { SHARED_DASHBOARD_QUERY } from 'app/plugins/datasource/dashboard';
|
||||
import { DASHBOARD_DATASOURCE_PLUGIN_ID } from 'app/plugins/datasource/dashboard/types';
|
||||
|
||||
@@ -112,12 +112,12 @@ describe('transformSaveModelToScene', () => {
|
||||
|
||||
describe('when organizing panels as scene children', () => {
|
||||
it('should create panels within collapsed rows', () => {
|
||||
const panel = createPanelJSONFixture({
|
||||
const panel = createPanelSaveModel({
|
||||
title: 'test',
|
||||
gridPos: { x: 1, y: 0, w: 12, h: 8 },
|
||||
}) as Panel;
|
||||
|
||||
const row = createPanelJSONFixture({
|
||||
const row = createPanelSaveModel({
|
||||
title: 'test',
|
||||
type: 'row',
|
||||
gridPos: { x: 0, y: 0, w: 12, h: 1 },
|
||||
@@ -146,7 +146,7 @@ describe('transformSaveModelToScene', () => {
|
||||
});
|
||||
|
||||
it('should create panels within expanded row', () => {
|
||||
const panelOutOfRow = createPanelJSONFixture({
|
||||
const panelOutOfRow = createPanelSaveModel({
|
||||
title: 'Out of a row',
|
||||
gridPos: {
|
||||
h: 8,
|
||||
@@ -155,7 +155,7 @@ describe('transformSaveModelToScene', () => {
|
||||
y: 0,
|
||||
},
|
||||
});
|
||||
const rowWithPanel = createPanelJSONFixture({
|
||||
const rowWithPanel = createPanelSaveModel({
|
||||
title: 'Row with panel',
|
||||
type: 'row',
|
||||
id: 10,
|
||||
@@ -169,7 +169,7 @@ describe('transformSaveModelToScene', () => {
|
||||
// This panels array is not used if the row is not collapsed
|
||||
panels: [],
|
||||
});
|
||||
const panelInRow = createPanelJSONFixture({
|
||||
const panelInRow = createPanelSaveModel({
|
||||
gridPos: {
|
||||
h: 8,
|
||||
w: 12,
|
||||
@@ -178,7 +178,7 @@ describe('transformSaveModelToScene', () => {
|
||||
},
|
||||
title: 'In row 1',
|
||||
});
|
||||
const emptyRow = createPanelJSONFixture({
|
||||
const emptyRow = createPanelSaveModel({
|
||||
collapsed: false,
|
||||
gridPos: {
|
||||
h: 1,
|
||||
|
@@ -374,7 +374,7 @@ describe('transformSceneToSaveModel', () => {
|
||||
|
||||
const result = gridItemToPanel(panel);
|
||||
|
||||
expect(result.transformations.length).toBe(1);
|
||||
expect(result.transformations?.length).toBe(1);
|
||||
|
||||
expect(result.maxDataPoints).toBe(100);
|
||||
expect(result.targets?.length).toBe(2);
|
||||
@@ -458,7 +458,7 @@ describe('transformSceneToSaveModel', () => {
|
||||
|
||||
const result = gridItemToPanel(panel);
|
||||
|
||||
expect(result.transformations.length).toBe(1);
|
||||
expect(result.transformations?.length).toBe(1);
|
||||
|
||||
expect(result.targets?.length).toBe(1);
|
||||
expect(result.targets?.[0]).toEqual({
|
||||
|
@@ -2,14 +2,14 @@ import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
|
||||
|
||||
import { ContextSrv, setContextSrv } from '../../../../core/services/context_srv';
|
||||
import { PanelModel } from '../../state/PanelModel';
|
||||
import { createDashboardModelFixture, createPanelJSONFixture } from '../../state/__fixtures__/dashboardFixtures';
|
||||
import { createDashboardModelFixture, createPanelSaveModel } from '../../state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import { hasChanges, ignoreChanges } from './DashboardPrompt';
|
||||
|
||||
function getDefaultDashboardModel() {
|
||||
return createDashboardModelFixture({
|
||||
panels: [
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
id: 1,
|
||||
type: 'graph',
|
||||
gridPos: { x: 0, y: 0, w: 24, h: 6 },
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { createDashboardModelFixture, createPanelJSONFixture } from '../../state/__fixtures__/dashboardFixtures';
|
||||
import { createDashboardModelFixture, createPanelSaveModel } from '../../state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import { openai } from './llms';
|
||||
import { getDashboardChanges, isLLMPluginEnabled, sanitizeReply } from './utils';
|
||||
@@ -21,7 +21,7 @@ describe('getDashboardChanges', () => {
|
||||
const deprecatedVersion = 37;
|
||||
const dashboard = createDashboardModelFixture({
|
||||
schemaVersion: deprecatedVersion,
|
||||
panels: [createPanelJSONFixture({ title: 'Panel 1', options: deprecatedOptions })],
|
||||
panels: [createPanelSaveModel({ title: 'Panel 1', options: deprecatedOptions })],
|
||||
});
|
||||
|
||||
// Update title for the first panel
|
||||
|
@@ -128,7 +128,6 @@ describe('DashboardModel', () => {
|
||||
{
|
||||
type: 'row',
|
||||
panels: [
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 501,
|
||||
type: 'table',
|
||||
@@ -845,7 +844,6 @@ describe('DashboardModel', () => {
|
||||
'# Angular Text Panel\n# $constant\n\nFor markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)\n\n## $text\n\n',
|
||||
mode: 'markdown',
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 3,
|
||||
type: 'text2',
|
||||
@@ -856,7 +854,6 @@ describe('DashboardModel', () => {
|
||||
'# React Text Panel from scratch\n# $constant\n\nFor markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)\n\n## $text',
|
||||
},
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 4,
|
||||
type: 'text2',
|
||||
@@ -1594,7 +1591,6 @@ describe('DashboardModel', () => {
|
||||
],
|
||||
},
|
||||
panels: [
|
||||
// @ts-expect-error
|
||||
{
|
||||
gridPos: {
|
||||
h: 8,
|
||||
@@ -1717,7 +1713,6 @@ describe('DashboardModel', () => {
|
||||
title: 'DynamoDB',
|
||||
type: 'row',
|
||||
panels: [
|
||||
// @ts-expect-error
|
||||
{
|
||||
gridPos: {
|
||||
h: 8,
|
||||
@@ -1772,7 +1767,6 @@ describe('DashboardModel', () => {
|
||||
title: 'Panel Title',
|
||||
type: 'timeseries',
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
gridPos: {
|
||||
h: 8,
|
||||
@@ -1982,8 +1976,8 @@ describe('DashboardModel', () => {
|
||||
describe('when migrating time series axis visibility', () => {
|
||||
test('preserves x axis visibility', () => {
|
||||
const model = new DashboardModel({
|
||||
schemaVersion: 25,
|
||||
panels: [
|
||||
// @ts-expect-error
|
||||
{
|
||||
type: 'timeseries',
|
||||
fieldConfig: {
|
||||
@@ -2204,7 +2198,6 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
beforeEach(() => {
|
||||
model = new DashboardModel({
|
||||
panels: [
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 1,
|
||||
type: 'table',
|
||||
@@ -2216,9 +2209,8 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
inspect: false,
|
||||
},
|
||||
},
|
||||
} as unknown as FieldConfigSource, // missing overrides
|
||||
} as unknown as FieldConfigSource, // missing overrides on purpose
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 2,
|
||||
type: 'table',
|
||||
@@ -2233,7 +2225,6 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
overrides: [],
|
||||
},
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 3,
|
||||
type: 'table',
|
||||
@@ -2248,7 +2239,6 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
overrides: [],
|
||||
},
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 4,
|
||||
type: 'table',
|
||||
@@ -2263,7 +2253,6 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
overrides: [],
|
||||
},
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 5,
|
||||
type: 'table',
|
||||
@@ -2278,7 +2267,6 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
overrides: [],
|
||||
},
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 6,
|
||||
type: 'table',
|
||||
@@ -2346,7 +2334,6 @@ describe('when migrating table cell display mode to cell options', () => {
|
||||
],
|
||||
},
|
||||
},
|
||||
// @ts-expect-error
|
||||
{
|
||||
id: 7,
|
||||
type: 'table',
|
||||
|
@@ -15,7 +15,7 @@ import { PanelModel } from '../state/PanelModel';
|
||||
import {
|
||||
createAnnotationJSONFixture,
|
||||
createDashboardModelFixture,
|
||||
createPanelJSONFixture,
|
||||
createPanelSaveModel,
|
||||
createVariableJSONFixture,
|
||||
} from './__fixtures__/dashboardFixtures';
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('DashboardModel', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
model = createDashboardModelFixture({
|
||||
panels: [createPanelJSONFixture({ id: 5 })],
|
||||
panels: [createPanelSaveModel({ id: 5 })],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -92,10 +92,10 @@ describe('DashboardModel', () => {
|
||||
beforeEach(() => {
|
||||
model = createDashboardModelFixture({
|
||||
panels: [
|
||||
createPanelJSONFixture({ id: 6 }),
|
||||
createPanelJSONFixture({ id: 2 }),
|
||||
createPanelJSONFixture({}), // undefined
|
||||
createPanelJSONFixture({ id: 2 }),
|
||||
createPanelSaveModel({ id: 6 }),
|
||||
createPanelSaveModel({ id: 2 }),
|
||||
createPanelSaveModel({}), // undefined
|
||||
createPanelSaveModel({ id: 2 }),
|
||||
],
|
||||
});
|
||||
});
|
||||
@@ -217,7 +217,7 @@ describe('DashboardModel', () => {
|
||||
model = createDashboardModelFixture({
|
||||
schemaVersion: 1,
|
||||
panels: [
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
type: 'graph',
|
||||
targets: [
|
||||
{
|
||||
@@ -418,11 +418,11 @@ describe('DashboardModel', () => {
|
||||
beforeEach(() => {
|
||||
dashboard = createDashboardModelFixture({
|
||||
panels: [
|
||||
createPanelJSONFixture({ id: 1, type: 'graph', gridPos: { x: 0, y: 0, w: 24, h: 2 } }),
|
||||
createPanelJSONFixture({ id: 2, type: 'row', gridPos: { x: 0, y: 2, w: 24, h: 2 } }),
|
||||
createPanelJSONFixture({ id: 3, type: 'graph', gridPos: { x: 0, y: 4, w: 12, h: 2 } }),
|
||||
createPanelJSONFixture({ id: 4, type: 'graph', gridPos: { x: 12, y: 4, w: 12, h: 2 } }),
|
||||
createPanelJSONFixture({ id: 5, type: 'row', gridPos: { x: 0, y: 6, w: 24, h: 2 } }),
|
||||
createPanelSaveModel({ id: 1, type: 'graph', gridPos: { x: 0, y: 0, w: 24, h: 2 } }),
|
||||
createPanelSaveModel({ id: 2, type: 'row', gridPos: { x: 0, y: 2, w: 24, h: 2 } }),
|
||||
createPanelSaveModel({ id: 3, type: 'graph', gridPos: { x: 0, y: 4, w: 12, h: 2 } }),
|
||||
createPanelSaveModel({ id: 4, type: 'graph', gridPos: { x: 12, y: 4, w: 12, h: 2 } }),
|
||||
createPanelSaveModel({ id: 5, type: 'row', gridPos: { x: 0, y: 6, w: 24, h: 2 } }),
|
||||
],
|
||||
});
|
||||
dashboard.toggleRow(dashboard.panels[1]);
|
||||
|
@@ -29,16 +29,8 @@ export function createDashboardModelFixture(
|
||||
return new DashboardModel(dashboardJson, meta, { getVariablesFromState });
|
||||
}
|
||||
|
||||
export function createPanelJSONFixture(panelInput: Partial<Panel | GraphPanel | RowPanel> = {}): Panel {
|
||||
export function createPanelSaveModel(panelInput: Partial<Panel | GraphPanel | RowPanel> = {}): Panel {
|
||||
return {
|
||||
fieldConfig: {
|
||||
defaults: {},
|
||||
overrides: [],
|
||||
},
|
||||
options: {},
|
||||
repeatDirection: 'h',
|
||||
transformations: [],
|
||||
transparent: false,
|
||||
type: 'timeseries',
|
||||
...panelInput,
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { DashboardInitPhase, DashboardState, OrgRole, PermissionLevel } from 'app/types';
|
||||
|
||||
import { createDashboardModelFixture, createPanelJSONFixture } from './__fixtures__/dashboardFixtures';
|
||||
import { createDashboardModelFixture, createPanelSaveModel } from './__fixtures__/dashboardFixtures';
|
||||
import {
|
||||
dashboardInitCompleted,
|
||||
dashboardInitFailed,
|
||||
@@ -37,7 +37,7 @@ describe('dashboard reducer', () => {
|
||||
dashboardInitCompleted(
|
||||
createDashboardModelFixture({
|
||||
title: 'My dashboard',
|
||||
panels: [createPanelJSONFixture({ id: 1 }), createPanelJSONFixture({ id: 2 })],
|
||||
panels: [createPanelSaveModel({ id: 1 }), createPanelSaveModel({ id: 2 })],
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@@ -2,7 +2,7 @@ import { PanelModel } from '@grafana/data';
|
||||
import { FieldColorModeId, ThresholdsMode } from '@grafana/schema/src';
|
||||
|
||||
import { DashboardModel } from '../state/DashboardModel';
|
||||
import { createDashboardModelFixture, createPanelJSONFixture } from '../state/__fixtures__/dashboardFixtures';
|
||||
import { createDashboardModelFixture, createPanelSaveModel } from '../state/__fixtures__/dashboardFixtures';
|
||||
|
||||
describe('Merge dashboard panels', () => {
|
||||
describe('simple changes', () => {
|
||||
@@ -13,15 +13,15 @@ describe('Merge dashboard panels', () => {
|
||||
dashboard = createDashboardModelFixture({
|
||||
title: 'simple title',
|
||||
panels: [
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
id: 1,
|
||||
type: 'timeseries',
|
||||
}),
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
id: 2,
|
||||
type: 'timeseries',
|
||||
}),
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
id: 3,
|
||||
type: 'table',
|
||||
fieldConfig: {
|
||||
|
@@ -10,7 +10,7 @@ import { DashboardModel } from 'app/features/dashboard/state';
|
||||
|
||||
import {
|
||||
createDashboardModelFixture,
|
||||
createPanelJSONFixture,
|
||||
createPanelSaveModel,
|
||||
} from '../../../features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import { DashboardQueryEditor } from './DashboardQueryEditor';
|
||||
@@ -49,19 +49,19 @@ describe('DashboardQueryEditor', () => {
|
||||
beforeEach(() => {
|
||||
mockDashboard = createDashboardModelFixture({
|
||||
panels: [
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
targets: [],
|
||||
type: 'timeseries',
|
||||
id: 1,
|
||||
title: 'My first panel',
|
||||
}),
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
targets: [],
|
||||
id: 2,
|
||||
type: 'timeseries',
|
||||
title: 'Another panel',
|
||||
}),
|
||||
createPanelJSONFixture({
|
||||
createPanelSaveModel({
|
||||
datasource: {
|
||||
uid: SHARED_DASHBOARD_QUERY,
|
||||
},
|
||||
|
Reference in New Issue
Block a user