diff --git a/docs/sources/developers/kinds/core/dashboard/schema-reference.md b/docs/sources/developers/kinds/core/dashboard/schema-reference.md index ef5c05b63fc..9b6a5348238 100644 --- a/docs/sources/developers/kinds/core/dashboard/schema-reference.md +++ b/docs/sources/developers/kinds/core/dashboard/schema-reference.md @@ -633,22 +633,21 @@ Configured template variables A variable is a placeholder for a value. You can use variables in metric queries and in panel titles. -| Property | Type | Required | Default | Description | -|---------------|-------------------------------------|----------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `hide` | integer | **Yes** | | Determine if the variable shows on dashboard
Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
Possible values are: `0`, `1`, `2`. | -| `id` | string | **Yes** | `00000000-0000-0000-0000-000000000000` | Unique numeric identifier for the variable. | -| `name` | string | **Yes** | | Name of variable | -| `skipUrlSync` | boolean | **Yes** | `false` | Whether the variable value should be managed by URL query params or not | -| `type` | string | **Yes** | | Dashboard variable type
`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
`constant`: Define a hidden constant.
`datasource`: Quickly change the data source for an entire dashboard.
`interval`: Interval variables represent time spans.
`textbox`: Display a free text input field with an optional default value.
`custom`: Define the variable options manually using a comma-separated list.
`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
Possible values are: `query`, `adhoc`, `constant`, `datasource`, `interval`, `textbox`, `custom`, `system`. | -| `allFormat` | string | No | | Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc. | -| `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. | -| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance | -| `description` | string | No | | Description of variable. It can be defined but `null`. | -| `label` | string | No | | Optional display name | -| `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list | -| `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. | -| `query` | | No | | Query used to fetch values for a variable | -| `refresh` | integer | No | | Options to config when to refresh a variable
`0`: Never refresh the variable
`1`: Queries the data source every time the dashboard loads.
`2`: Queries the data source when the dashboard time range changes.
Possible values are: `0`, `1`, `2`. | +| Property | Type | Required | Default | Description | +|---------------|-------------------------------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `name` | string | **Yes** | | Name of variable | +| `type` | string | **Yes** | | Dashboard variable type
`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
`constant`: Define a hidden constant.
`datasource`: Quickly change the data source for an entire dashboard.
`interval`: Interval variables represent time spans.
`textbox`: Display a free text input field with an optional default value.
`custom`: Define the variable options manually using a comma-separated list.
`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
Possible values are: `query`, `adhoc`, `constant`, `datasource`, `interval`, `textbox`, `custom`, `system`. | +| `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. | +| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance | +| `description` | string | No | | Description of variable. It can be defined but `null`. | +| `hide` | integer | No | | Determine if the variable shows on dashboard
Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
Possible values are: `0`, `1`, `2`. | +| `label` | string | No | | Optional display name | +| `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list | +| `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. | +| `query` | | No | | Query used to fetch values for a variable | +| `refresh` | integer | No | | Options to config when to refresh a variable
`0`: Never refresh the variable
`1`: Queries the data source every time the dashboard loads.
`2`: Queries the data source when the dashboard time range changes.
Possible values are: `0`, `1`, `2`. | +| `skipUrlSync` | boolean | No | `false` | Whether the variable value should be managed by URL query params or not | +| `sort` | integer | No | | Sort variable options
Accepted values are:
`0`: No sorting
`1`: Alphabetical ASC
`2`: Alphabetical DESC
`3`: Numerical ASC
`4`: Numerical DESC
`5`: Alphabetical Case Insensitive ASC
`6`: Alphabetical Case Insensitive DESC
Possible values are: `0`, `1`, `2`, `3`, `4`, `5`, `6`. | ### VariableOption diff --git a/kinds/dashboard/dashboard_kind.cue b/kinds/dashboard/dashboard_kind.cue index 2ea9137b538..20bb612354a 100644 --- a/kinds/dashboard/dashboard_kind.cue +++ b/kinds/dashboard/dashboard_kind.cue @@ -183,8 +183,6 @@ lineage: schemas: [{ // A variable is a placeholder for a value. You can use variables in metric queries and in panel titles. #VariableModel: { - // Unique numeric identifier for the variable. - id: string | *"00000000-0000-0000-0000-000000000000" // Type of variable type: #VariableType // Name of variable @@ -192,17 +190,15 @@ lineage: schemas: [{ // Optional display name label?: string // Visibility configuration for the variable - hide: #VariableHide + hide?: #VariableHide // Whether the variable value should be managed by URL query params or not - skipUrlSync: bool | *false + skipUrlSync?: bool | *false // Description of variable. It can be defined but `null`. description?: string // Query used to fetch values for a variable query?: string | {...} // Data source used to fetch values for a variable. It can be defined but `null`. datasource?: #DataSourceRef - // Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc. - allFormat?: string // Shows current selected variable text/value on the dashboard current?: #VariableOption // Whether multiple values can be selected or not from variable value list @@ -210,6 +206,8 @@ lineage: schemas: [{ // Options that can be selected for a variable. options?: [...#VariableOption] refresh?: #VariableRefresh + // Options sort order + sort?: #VariableSort ... } @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview) @@ -244,10 +242,6 @@ lineage: schemas: [{ // `6`: Alphabetical Case Insensitive DESC #VariableSort: 0 | 1 | 2 | 3 | 4 | 5 | 6 @cuetsy(kind="enum",memberNames="disabled|alphabeticalAsc|alphabeticalDesc|numericalAsc|numericalDesc|alphabeticalCaseInsensitiveAsc|alphabeticalCaseInsensitiveDesc") - // Loading status - // Accepted values are `NotStarted` (the request is not started), `Loading` (waiting for response), `Streaming` (pulling continuous data), `Done` (response received successfully) or `Error` (failed request). - #LoadingState: "NotStarted" | "Loading" | "Streaming" | "Done" | "Error" @cuetsy(kind="enum") - // Ref to a DataSource instance #DataSourceRef: { // The plugin type-id diff --git a/packages/grafana-schema/src/index.gen.ts b/packages/grafana-schema/src/index.gen.ts index e47906f4c77..7d1d3d05068 100644 --- a/packages/grafana-schema/src/index.gen.ts +++ b/packages/grafana-schema/src/index.gen.ts @@ -48,7 +48,6 @@ export { defaultAnnotationPanelFilter, VariableRefresh, VariableSort, - LoadingState, defaultDashboardLink, FieldColorModeId, defaultGridPos, diff --git a/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts b/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts index 915757e5cd9..e86774a7f7b 100644 --- a/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts +++ b/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts @@ -121,10 +121,6 @@ export const defaultAnnotationQuery: Partial = { * A variable is a placeholder for a value. You can use variables in metric queries and in panel titles. */ export interface VariableModel { - /** - * Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc. - */ - allFormat?: string; /** * Shows current selected variable text/value on the dashboard */ @@ -140,11 +136,7 @@ export interface VariableModel { /** * Visibility configuration for the variable */ - hide: VariableHide; - /** - * Unique numeric identifier for the variable. - */ - id: string; + hide?: VariableHide; /** * Optional display name */ @@ -169,7 +161,11 @@ export interface VariableModel { /** * Whether the variable value should be managed by URL query params or not */ - skipUrlSync: boolean; + skipUrlSync?: boolean; + /** + * Options sort order + */ + sort?: VariableSort; /** * Type of variable */ @@ -177,7 +173,6 @@ export interface VariableModel { } export const defaultVariableModel: Partial = { - id: '00000000-0000-0000-0000-000000000000', multi: false, options: [], skipUrlSync: false, @@ -244,18 +239,6 @@ export enum VariableSort { numericalDesc = 4, } -/** - * Loading status - * Accepted values are `NotStarted` (the request is not started), `Loading` (waiting for response), `Streaming` (pulling continuous data), `Done` (response received successfully) or `Error` (failed request). - */ -export enum LoadingState { - Done = 'Done', - Error = 'Error', - Loading = 'Loading', - NotStarted = 'NotStarted', - Streaming = 'Streaming', -} - /** * Ref to a DataSource instance */ diff --git a/packages/grafana-schema/src/veneer/common.types.ts b/packages/grafana-schema/src/veneer/common.types.ts index 2ece21b6e66..8a73c1149f9 100644 --- a/packages/grafana-schema/src/veneer/common.types.ts +++ b/packages/grafana-schema/src/veneer/common.types.ts @@ -45,3 +45,15 @@ export const defaultTableFieldOptions: raw.TableFieldOptions = { type: raw.TableCellDisplayMode.Auto, }, }; + +/** + * Represent panel data loading state. + * @deprecated Please use LoadingState from @grafana/data + */ +export enum LoadingState { + NotStarted = 'NotStarted', + Loading = 'Loading', + Streaming = 'Streaming', + Done = 'Done', + Error = 'Error', +} diff --git a/packages/grafana-schema/src/veneer/dashboard.types.ts b/packages/grafana-schema/src/veneer/dashboard.types.ts index e9226e10bbb..1d3522622ea 100644 --- a/packages/grafana-schema/src/veneer/dashboard.types.ts +++ b/packages/grafana-schema/src/veneer/dashboard.types.ts @@ -20,10 +20,8 @@ export enum VariableHide { hideVariable, } -export interface VariableModel extends Omit { - hide: VariableHide; - description?: string | null; - datasource: DataSourceRef | null; +export interface VariableModel extends Omit { + datasource?: DataSourceRef | null; } export interface Dashboard extends Omit { @@ -63,9 +61,6 @@ export interface DataTransformerConfig extends raw.DataTransform export const defaultDashboard = raw.defaultDashboard as Dashboard; export const defaultVariableModel = { ...raw.defaultVariableModel, - description: null, - hide: VariableHide.dontHide, - datasource: null, } as VariableModel; export const defaultPanel: Partial = raw.defaultPanel; export const defaultRowPanel: Partial = raw.defaultRowPanel; diff --git a/pkg/kinds/dashboard/dashboard_spec_gen.go b/pkg/kinds/dashboard/dashboard_spec_gen.go index 867ae14949e..145ae289ca3 100644 --- a/pkg/kinds/dashboard/dashboard_spec_gen.go +++ b/pkg/kinds/dashboard/dashboard_spec_gen.go @@ -143,6 +143,17 @@ const ( VariableRefreshN2 VariableRefresh = 2 ) +// Defines values for VariableSort. +const ( + VariableSortN0 VariableSort = 0 + VariableSortN1 VariableSort = 1 + VariableSortN2 VariableSort = 2 + VariableSortN3 VariableSort = 3 + VariableSortN4 VariableSort = 4 + VariableSortN5 VariableSort = 5 + VariableSortN6 VariableSort = 6 +) + // Defines values for VariableType. const ( VariableTypeAdhoc VariableType = "adhoc" @@ -900,9 +911,6 @@ type VariableHide int // A variable is a placeholder for a value. You can use variables in metric queries and in panel titles. type VariableModel struct { - // Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc. - AllFormat *string `json:"allFormat,omitempty"` - // Option to be selected in a variable. Current *VariableOption `json:"current,omitempty"` @@ -914,10 +922,7 @@ type VariableModel struct { // Determine if the variable shows on dashboard // Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing). - Hide VariableHide `json:"hide"` - - // Unique numeric identifier for the variable. - Id string `json:"id"` + Hide *VariableHide `json:"hide,omitempty"` // Optional display name Label *string `json:"label,omitempty"` @@ -941,7 +946,18 @@ type VariableModel struct { Refresh *VariableRefresh `json:"refresh,omitempty"` // Whether the variable value should be managed by URL query params or not - SkipUrlSync bool `json:"skipUrlSync"` + SkipUrlSync *bool `json:"skipUrlSync,omitempty"` + + // Sort variable options + // Accepted values are: + // `0`: No sorting + // `1`: Alphabetical ASC + // `2`: Alphabetical DESC + // `3`: Numerical ASC + // `4`: Numerical DESC + // `5`: Alphabetical Case Insensitive ASC + // `6`: Alphabetical Case Insensitive DESC + Sort *VariableSort `json:"sort,omitempty"` // Dashboard variable type // `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. @@ -973,6 +989,17 @@ type VariableOption struct { // `2`: Queries the data source when the dashboard time range changes. type VariableRefresh int +// Sort variable options +// Accepted values are: +// `0`: No sorting +// `1`: Alphabetical ASC +// `2`: Alphabetical DESC +// `3`: Numerical ASC +// `4`: Numerical DESC +// `5`: Alphabetical Case Insensitive ASC +// `6`: Alphabetical Case Insensitive DESC +type VariableSort int + // Dashboard variable type // `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. // `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). diff --git a/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx b/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx index 89416127d04..3fe2feb640f 100644 --- a/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx @@ -2,9 +2,9 @@ import { css } from '@emotion/css'; import React, { FC, useEffect, useState } from 'react'; import { useAsync } from 'react-use'; -import { PanelData, CoreApp, GrafanaTheme2 } from '@grafana/data'; +import { PanelData, CoreApp, GrafanaTheme2, LoadingState } from '@grafana/data'; import { getDataSourceSrv } from '@grafana/runtime'; -import { DataQuery, LoadingState } from '@grafana/schema'; +import { DataQuery } from '@grafana/schema'; import { useStyles2 } from '@grafana/ui'; import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv'; import { AlertQuery } from 'app/types/unified-alerting-dto'; diff --git a/public/app/features/alerting/unified/components/rule-editor/util.ts b/public/app/features/alerting/unified/components/rule-editor/util.ts index d0f0c31e536..f0eefd50da9 100644 --- a/public/app/features/alerting/unified/components/rule-editor/util.ts +++ b/public/app/features/alerting/unified/components/rule-editor/util.ts @@ -1,8 +1,15 @@ import { xor } from 'lodash'; import { ValidateResult } from 'react-hook-form'; -import { DataFrame, ThresholdsConfig, ThresholdsMode, isTimeSeriesFrames, PanelData } from '@grafana/data'; -import { GraphTresholdsStyleMode, LoadingState } from '@grafana/schema'; +import { + DataFrame, + ThresholdsConfig, + ThresholdsMode, + isTimeSeriesFrames, + PanelData, + LoadingState, +} from '@grafana/data'; +import { GraphTresholdsStyleMode } from '@grafana/schema'; import { config } from 'app/core/config'; import { EvalFunction } from 'app/features/alerting/state/alertDef'; import { isExpressionQuery } from 'app/features/expressions/guards'; diff --git a/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.test.ts b/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.test.ts index e6faf39203e..039f6b8ccef 100644 --- a/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.test.ts +++ b/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.test.ts @@ -1,7 +1,6 @@ import { map, of } from 'rxjs'; -import { DataSourceApi, DataQueryRequest, PanelData } from '@grafana/data'; -import { LoadingState } from '@grafana/schema'; +import { DataSourceApi, DataQueryRequest, PanelData, LoadingState } from '@grafana/data'; import { PublicAnnotationsDataSource } from 'app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource'; import { DashboardAnnotationsDataLayer } from './DashboardAnnotationsDataLayer'; diff --git a/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.ts b/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.ts index 52d2957ea29..f6187f92930 100644 --- a/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.ts +++ b/public/app/features/dashboard-scene/scene/DashboardAnnotationsDataLayer.ts @@ -1,7 +1,14 @@ -import { AnnotationEvent, arrayToDataFrame, DataTopic, getDefaultTimeRange, PanelData } from '@grafana/data'; +import { + AnnotationEvent, + arrayToDataFrame, + DataTopic, + getDefaultTimeRange, + PanelData, + LoadingState, +} from '@grafana/data'; import { config } from '@grafana/runtime'; import { dataLayers } from '@grafana/scenes'; -import { AnnotationQuery, LoadingState } from '@grafana/schema'; +import { AnnotationQuery } from '@grafana/schema'; import { PublicAnnotationsDataSource } from 'app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource'; /** diff --git a/public/app/features/dashboard-scene/scene/ShareQueryDataProvider.ts b/public/app/features/dashboard-scene/scene/ShareQueryDataProvider.ts index 8b8137d49a7..713edc10e6f 100644 --- a/public/app/features/dashboard-scene/scene/ShareQueryDataProvider.ts +++ b/public/app/features/dashboard-scene/scene/ShareQueryDataProvider.ts @@ -1,6 +1,6 @@ import { Observable, ReplaySubject, Unsubscribable } from 'rxjs'; -import { getDefaultTimeRange } from '@grafana/data'; +import { getDefaultTimeRange, LoadingState } from '@grafana/data'; import { SceneDataProvider, SceneDataProviderResult, @@ -10,7 +10,6 @@ import { SceneObject, SceneObjectBase, } from '@grafana/scenes'; -import { LoadingState } from '@grafana/schema'; import { DashboardQuery } from 'app/plugins/datasource/dashboard/types'; import { getVizPanelKeyForPanelId } from '../utils/utils'; diff --git a/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.test.ts b/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.test.ts index b4ef6335970..13f9f43c172 100644 --- a/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.test.ts +++ b/public/app/features/dashboard-scene/serialization/transformSaveModelToScene.test.ts @@ -1,3 +1,4 @@ +import { LoadingState } from '@grafana/data'; import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; import { config } from '@grafana/runtime'; import { @@ -14,7 +15,7 @@ import { SceneQueryRunner, VizPanel, } from '@grafana/scenes'; -import { DashboardCursorSync, defaultDashboard, LoadingState, Panel, RowPanel, VariableType } from '@grafana/schema'; +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 { SHARED_DASHBOARD_QUERY } from 'app/plugins/datasource/dashboard'; diff --git a/public/app/features/dashboard/state/DashboardMigrator.test.ts b/public/app/features/dashboard/state/DashboardMigrator.test.ts index 2fbc82457a4..c502d8ff682 100644 --- a/public/app/features/dashboard/state/DashboardMigrator.test.ts +++ b/public/app/features/dashboard/state/DashboardMigrator.test.ts @@ -59,7 +59,7 @@ describe('DashboardModel', () => { beforeEach(() => { model = new DashboardModel({ services: { - filter: { time: { from: 'now-1d', to: 'now' }, list: [{}] }, + filter: { time: { from: 'now-1d', to: 'now' }, list: [{ name: 'server' }] }, }, pulldowns: [ { type: 'filtering', enable: true }, @@ -165,7 +165,7 @@ describe('DashboardModel', () => { it('should move time and filtering list', () => { expect(model.time.from).toBe('now-1d'); - expect(model.templating.list[0].allFormat).toBe('glob'); + expect(model.templating.list[0].name).toBe('server'); }); it('graphite panel should change name too graph', () => { @@ -921,58 +921,55 @@ describe('DashboardModel', () => { beforeEach(() => { model = new DashboardModel({ + editable: true, + graphTooltip: 0, + schemaVersion: 10, templating: { list: [ - // @ts-expect-error { + name: 'server1', type: 'query', hide: VariableHide.dontHide, datasource: null, - allFormat: '', }, - // @ts-expect-error { + name: 'server2', type: 'query', hide: VariableHide.hideLabel, datasource: null, - allFormat: '', }, - // @ts-expect-error { + name: 'server3', type: 'query', hide: VariableHide.hideVariable, datasource: null, - allFormat: '', }, - // @ts-expect-error { + name: 'server4', type: 'constant', hide: VariableHide.dontHide, query: 'default value', current: { selected: true, text: 'A', value: 'B' }, options: [{ selected: true, text: 'A', value: 'B' }], datasource: null, - allFormat: '', }, - // @ts-expect-error { + name: 'server5', type: 'constant', hide: VariableHide.hideLabel, query: 'default value', current: { selected: true, text: 'A', value: 'B' }, options: [{ selected: true, text: 'A', value: 'B' }], datasource: null, - allFormat: '', }, - // @ts-expect-error { + name: 'server6', type: 'constant', hide: VariableHide.hideVariable, query: 'default value', current: { selected: true, text: 'A', value: 'B' }, options: [{ selected: true, text: 'A', value: 'B' }], datasource: null, - allFormat: '', }, ], }, @@ -991,34 +988,34 @@ describe('DashboardModel', () => { it('should migrate visible constant variables to textbox variables', () => { expect(model.templating.list[3]).toEqual({ + name: 'server4', type: 'textbox', hide: VariableHide.dontHide, query: 'default value', current: { selected: true, text: 'default value', value: 'default value' }, options: [{ selected: true, text: 'default value', value: 'default value' }], datasource: null, - allFormat: '', }); expect(model.templating.list[4]).toEqual({ + name: 'server5', type: 'textbox', hide: VariableHide.hideLabel, query: 'default value', current: { selected: true, text: 'default value', value: 'default value' }, options: [{ selected: true, text: 'default value', value: 'default value' }], datasource: null, - allFormat: '', }); }); it('should change current and options for hidden constant variables', () => { expect(model.templating.list[5]).toEqual({ + name: 'server6', type: 'constant', hide: VariableHide.hideVariable, query: 'default value', current: { selected: true, text: 'default value', value: 'default value' }, options: [{ selected: true, text: 'default value', value: 'default value' }], datasource: null, - allFormat: '', }); }); }); @@ -1028,95 +1025,84 @@ describe('DashboardModel', () => { beforeEach(() => { model = new DashboardModel({ + editable: true, + graphTooltip: 0, + schemaVersion: 20, templating: { list: [ - // @ts-expect-error { type: 'query', name: 'variable_with_never_refresh_with_options', options: [{ text: 'A', value: 'A' }], refresh: 0, }, - // @ts-expect-error { type: 'query', name: 'variable_with_never_refresh_without_options', options: [], refresh: 0, }, - // @ts-expect-error { type: 'query', name: 'variable_with_dashboard_refresh_with_options', options: [{ text: 'A', value: 'A' }], refresh: 1, }, - // @ts-expect-error { type: 'query', name: 'variable_with_dashboard_refresh_without_options', options: [], refresh: 1, }, - // @ts-expect-error { type: 'query', name: 'variable_with_timerange_refresh_with_options', options: [{ text: 'A', value: 'A' }], refresh: 2, }, - // @ts-expect-error { type: 'query', name: 'variable_with_timerange_refresh_without_options', options: [], refresh: 2, }, - // @ts-expect-error { type: 'query', name: 'variable_with_no_refresh_with_options', options: [{ text: 'A', value: 'A' }], }, - // @ts-expect-error { type: 'query', name: 'variable_with_no_refresh_without_options', options: [], }, - // @ts-expect-error { type: 'query', name: 'variable_with_unknown_refresh_with_options', options: [{ text: 'A', value: 'A' }], refresh: 2001, }, - // @ts-expect-error { type: 'query', name: 'variable_with_unknown_refresh_without_options', options: [], refresh: 2001, }, - // @ts-expect-error { type: 'custom', name: 'custom', options: [{ text: 'custom', value: 'custom' }], }, - // @ts-expect-error { type: 'textbox', name: 'textbox', options: [{ text: 'Hello', value: 'World' }], }, - // @ts-expect-error { type: 'datasource', name: 'datasource', options: [{ text: 'ds', value: 'ds' }], // fake example doesn't exist }, - // @ts-expect-error { type: 'interval', name: 'interval', @@ -2038,7 +2024,6 @@ describe('DashboardModel', () => { model = new DashboardModel({ templating: { list: [ - // @ts-expect-error { type: 'query', name: 'var', diff --git a/public/app/features/dashboard/state/DashboardMigrator.ts b/public/app/features/dashboard/state/DashboardMigrator.ts index 4c800df104c..5ebed64deea 100644 --- a/public/app/features/dashboard/state/DashboardMigrator.ts +++ b/public/app/features/dashboard/state/DashboardMigrator.ts @@ -195,7 +195,7 @@ export class DashboardMigrator { variable.type = 'query'; } if (variable.allFormat === void 0) { - variable.allFormat = 'glob'; + delete variable.allFormat; } } } diff --git a/public/app/features/logs/components/log-context/LogRowContextModal.tsx b/public/app/features/logs/components/log-context/LogRowContextModal.tsx index 144e3e3ae77..3fc878a6915 100644 --- a/public/app/features/logs/components/log-context/LogRowContextModal.tsx +++ b/public/app/features/logs/components/log-context/LogRowContextModal.tsx @@ -14,9 +14,10 @@ import { LogsSortOrder, dateTime, TimeRange, + LoadingState, } from '@grafana/data'; import { config, reportInteraction } from '@grafana/runtime'; -import { DataQuery, LoadingState, TimeZone } from '@grafana/schema'; +import { DataQuery, TimeZone } from '@grafana/schema'; import { Button, Modal, useTheme2 } from '@grafana/ui'; import store from 'app/core/store'; import { SETTINGS_KEYS } from 'app/features/explore/Logs/utils/logs'; diff --git a/public/app/plugins/datasource/loki/querySplitting.test.ts b/public/app/plugins/datasource/loki/querySplitting.test.ts index 61701843c75..f92dd4c03ac 100644 --- a/public/app/plugins/datasource/loki/querySplitting.test.ts +++ b/public/app/plugins/datasource/loki/querySplitting.test.ts @@ -1,8 +1,7 @@ import { of } from 'rxjs'; import { getQueryOptions } from 'test/helpers/getQueryOptions'; -import { dateTime } from '@grafana/data'; -import { LoadingState } from '@grafana/schema'; +import { dateTime, LoadingState } from '@grafana/data'; import { LokiDatasource } from './datasource'; import * as logsTimeSplit from './logsTimeSplitting'; diff --git a/public/app/plugins/datasource/loki/querySplitting.ts b/public/app/plugins/datasource/loki/querySplitting.ts index f2a5e9d6a0b..c9a7a25247e 100644 --- a/public/app/plugins/datasource/loki/querySplitting.ts +++ b/public/app/plugins/datasource/loki/querySplitting.ts @@ -12,8 +12,8 @@ import { parseDuration, rangeUtil, TimeRange, + LoadingState, } from '@grafana/data'; -import { LoadingState } from '@grafana/schema'; import { LokiDatasource } from './datasource'; import { splitTimeRange as splitLogsTimeRange } from './logsTimeSplitting';