mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Co-authored-by: Adela Almasan <adela.almasan@grafana.com> Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import {
|
|
AnnotationQuery,
|
|
Dashboard,
|
|
defaultDashboardCursorSync,
|
|
defaultVariableModel,
|
|
GraphPanel,
|
|
Panel,
|
|
RowPanel,
|
|
VariableModel,
|
|
} from '@grafana/schema';
|
|
import { GetVariables } from 'app/features/variables/state/selectors';
|
|
import { DashboardMeta } from 'app/types';
|
|
|
|
import { DashboardModel } from '../DashboardModel';
|
|
|
|
export function createDashboardModelFixture(
|
|
dashboardInput: Partial<Dashboard> = {},
|
|
meta?: DashboardMeta,
|
|
getVariablesFromState?: GetVariables
|
|
): DashboardModel {
|
|
const dashboardJson: Dashboard = {
|
|
editable: true,
|
|
graphTooltip: defaultDashboardCursorSync,
|
|
schemaVersion: 1,
|
|
style: 'dark',
|
|
timezone: '',
|
|
...dashboardInput,
|
|
};
|
|
|
|
return new DashboardModel(dashboardJson, meta, { getVariablesFromState });
|
|
}
|
|
|
|
export function createPanelJSONFixture(panelInput: Partial<Panel | GraphPanel | RowPanel> = {}): Panel {
|
|
return {
|
|
fieldConfig: {
|
|
defaults: {},
|
|
overrides: [],
|
|
},
|
|
options: {},
|
|
repeatDirection: 'h',
|
|
transformations: [],
|
|
transparent: false,
|
|
type: 'timeseries',
|
|
...panelInput,
|
|
};
|
|
}
|
|
|
|
export function createAnnotationJSONFixture(annotationInput: Partial<AnnotationQuery>): AnnotationQuery {
|
|
// @ts-expect-error
|
|
return {
|
|
datasource: {
|
|
type: 'foo',
|
|
uid: 'bar',
|
|
},
|
|
enable: true,
|
|
type: 'anno',
|
|
...annotationInput,
|
|
};
|
|
}
|
|
|
|
export function createVariableJSONFixture(annotationInput: Partial<VariableModel>): VariableModel {
|
|
return {
|
|
...defaultVariableModel,
|
|
name: 'foo.variable',
|
|
type: 'constant',
|
|
...annotationInput,
|
|
};
|
|
}
|