grafana/public/app/features/scenes/builders/panelBuilders.ts
Victor Marin a91e0a49c9
Migrate table to cue model (#61852)
* WIP table cue model

* WIP table types migration

* refactor

* WIP table cue

* docs

* veneer fix, docs

* docs
2023-03-01 17:48:36 +02:00

32 lines
1.1 KiB
TypeScript

import { VizPanel, VizPanelState } from '@grafana/scenes';
import { GraphFieldConfig, TableFieldOptions } from '@grafana/schema';
import { PanelOptions as BarGaugePanelOptions } from 'app/plugins/panel/bargauge/panelcfg.gen';
import { PanelOptions as TablePanelOptions } from 'app/plugins/panel/table/panelcfg.gen';
import { TimeSeriesOptions } from 'app/plugins/panel/timeseries/types';
export type TypedVizPanelState<TOptions, TFieldConfig> = Omit<
Partial<VizPanelState<TOptions, TFieldConfig>>,
'pluginId'
>;
export const panelBuilders = {
newTable: (state: TypedVizPanelState<TablePanelOptions, TableFieldOptions>) => {
return new VizPanel<TablePanelOptions, TableFieldOptions>({
...state,
pluginId: 'table',
});
},
newGraph: (state: TypedVizPanelState<TimeSeriesOptions, GraphFieldConfig>) => {
return new VizPanel({
...state,
pluginId: 'timeseries',
});
},
newBarGauge: (state: TypedVizPanelState<BarGaugePanelOptions, {}>) => {
return new VizPanel({
...state,
pluginId: 'bargauge',
});
},
};