mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Schema: Clean up dashboard variables schema (#76121)
* Cleanup variable schema model * minor fix * remove type ignores that are no longer type errors
This commit is contained in:
parent
69142bffe9
commit
fc0933d5f4
@ -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<br/>Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).<br/>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<br/>`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.<br/>`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).<br/>`constant`: Define a hidden constant.<br/>`datasource`: Quickly change the data source for an entire dashboard.<br/>`interval`: Interval variables represent time spans.<br/>`textbox`: Display a free text input field with an optional default value.<br/>`custom`: Define the variable options manually using a comma-separated list.<br/>`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables<br/>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<br/>`0`: Never refresh the variable<br/>`1`: Queries the data source every time the dashboard loads.<br/>`2`: Queries the data source when the dashboard time range changes.<br/>Possible values are: `0`, `1`, `2`. |
|
||||
| Property | Type | Required | Default | Description |
|
||||
|---------------|-------------------------------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `name` | string | **Yes** | | Name of variable |
|
||||
| `type` | string | **Yes** | | Dashboard variable type<br/>`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.<br/>`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).<br/>`constant`: Define a hidden constant.<br/>`datasource`: Quickly change the data source for an entire dashboard.<br/>`interval`: Interval variables represent time spans.<br/>`textbox`: Display a free text input field with an optional default value.<br/>`custom`: Define the variable options manually using a comma-separated list.<br/>`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables<br/>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<br/>Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).<br/>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<br/>`0`: Never refresh the variable<br/>`1`: Queries the data source every time the dashboard loads.<br/>`2`: Queries the data source when the dashboard time range changes.<br/>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<br/>Accepted values are:<br/>`0`: No sorting<br/>`1`: Alphabetical ASC<br/>`2`: Alphabetical DESC<br/>`3`: Numerical ASC<br/>`4`: Numerical DESC<br/>`5`: Alphabetical Case Insensitive ASC<br/>`6`: Alphabetical Case Insensitive DESC<br/>Possible values are: `0`, `1`, `2`, `3`, `4`, `5`, `6`. |
|
||||
|
||||
### VariableOption
|
||||
|
||||
|
@ -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
|
||||
|
@ -48,7 +48,6 @@ export {
|
||||
defaultAnnotationPanelFilter,
|
||||
VariableRefresh,
|
||||
VariableSort,
|
||||
LoadingState,
|
||||
defaultDashboardLink,
|
||||
FieldColorModeId,
|
||||
defaultGridPos,
|
||||
|
@ -121,10 +121,6 @@ export const defaultAnnotationQuery: Partial<AnnotationQuery> = {
|
||||
* 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<VariableModel> = {
|
||||
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
|
||||
*/
|
||||
|
@ -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',
|
||||
}
|
||||
|
@ -20,10 +20,8 @@ export enum VariableHide {
|
||||
hideVariable,
|
||||
}
|
||||
|
||||
export interface VariableModel extends Omit<raw.VariableModel, 'hide' | 'description' | 'datasource'> {
|
||||
hide: VariableHide;
|
||||
description?: string | null;
|
||||
datasource: DataSourceRef | null;
|
||||
export interface VariableModel extends Omit<raw.VariableModel, 'datasource'> {
|
||||
datasource?: DataSourceRef | null;
|
||||
}
|
||||
|
||||
export interface Dashboard extends Omit<raw.Dashboard, 'templating' | 'annotations' | 'panels'> {
|
||||
@ -63,9 +61,6 @@ export interface DataTransformerConfig<TOptions = any> 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<Panel> = raw.defaultPanel;
|
||||
export const defaultRowPanel: Partial<Panel> = raw.defaultRowPanel;
|
||||
|
@ -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).
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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',
|
||||
|
@ -195,7 +195,7 @@ export class DashboardMigrator {
|
||||
variable.type = 'query';
|
||||
}
|
||||
if (variable.allFormat === void 0) {
|
||||
variable.allFormat = 'glob';
|
||||
delete variable.allFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user