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:
Torkel Ödegaard
2023-10-09 09:10:52 +02:00
committed by GitHub
parent 69142bffe9
commit fc0933d5f4
18 changed files with 120 additions and 113 deletions
-1
View File
@@ -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;