Commit 49550cce by Johannes Schill

wip: panel-header: More merge conflicts during cherry pick

parent dbf7f3fb
...@@ -125,7 +125,7 @@ export class DashboardPanel extends PureComponent<Props, State> { ...@@ -125,7 +125,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
// withMenuOptions={pluginExports.withMenuOptions} // withMenuOptions={pluginExports.withMenuOptions}
panel={this.props.panel} panel={this.props.panel}
dashboard={this.props.dashboard} dashboard={this.props.dashboard}
moduleMenu={pluginExports.moduleMenu} getMenuAdditional={pluginExports.getMenuAdditional}
/> />
</div> </div>
{this.props.panel.isEditing && ( {this.props.panel.isEditing && (
......
...@@ -14,14 +14,14 @@ import { PanelHeaderMenu } from './PanelHeader/PanelHeaderMenu'; ...@@ -14,14 +14,14 @@ import { PanelHeaderMenu } from './PanelHeader/PanelHeaderMenu';
import { PanelModel } from '../panel_model'; import { PanelModel } from '../panel_model';
import { DashboardModel } from '../dashboard_model'; import { DashboardModel } from '../dashboard_model';
import { TimeRange, PanelProps, TimeSeries } from 'app/types'; import { TimeRange, PanelProps, TimeSeries } from 'app/types';
import { PanelHeaderGetMenuAdditional } from 'app/types/panel';
import { DataSourceApi } from 'app/types/series'; import { DataSourceApi } from 'app/types/series';
export interface PanelChromeProps { export interface PanelChromeProps {
panel: PanelModel; panel: PanelModel;
dashboard: DashboardModel; dashboard: DashboardModel;
component: ComponentClass<PanelProps>; component: ComponentClass<PanelProps>;
// withMenuOptions?: (c: typeof PanelHeaderMenu, p: PanelModel) => typeof PanelHeaderMenu; getMenuAdditional?: PanelHeaderGetMenuAdditional;
moduleMenu?: any;
} }
export interface PanelChromeState { export interface PanelChromeState {
...@@ -52,7 +52,7 @@ export class PanelChrome extends PureComponent<PanelChromeProps, PanelChromeStat ...@@ -52,7 +52,7 @@ export class PanelChrome extends PureComponent<PanelChromeProps, PanelChromeStat
try { try {
const dataSourceSrv = getDatasourceSrv(); const dataSourceSrv = getDatasourceSrv();
const dataSourceApi = await dataSourceSrv.get(datasource); const dataSourceApi = await dataSourceSrv.get(datasource);
this.setState(prevState => ({ this.setState((prevState: PanelChromeState) => ({
...prevState, ...prevState,
dataSourceApi, dataSourceApi,
})); }));
...@@ -95,11 +95,12 @@ export class PanelChrome extends PureComponent<PanelChromeProps, PanelChromeStat ...@@ -95,11 +95,12 @@ export class PanelChrome extends PureComponent<PanelChromeProps, PanelChromeStat
} }
render() { render() {
const { panel, dashboard, moduleMenu } = this.props; const { panel, dashboard, getMenuAdditional } = this.props;
const { refreshCounter, timeRange, dataSourceApi, timeSeries, renderCounter } = this.state; const { refreshCounter, timeRange, dataSourceApi, timeSeries, renderCounter } = this.state;
const { targets } = panel; const { targets } = panel;
const PanelComponent = this.props.component; const PanelComponent = this.props.component;
const panelSpecificMenuOptions = moduleMenu(panel, dataSourceApi, timeSeries); const panelSpecificMenuOptions = getMenuAdditional(panel, dataSourceApi, timeSeries);
const additionalMenuItems = panelSpecificMenuOptions.additionalMenuItems || undefined; const additionalMenuItems = panelSpecificMenuOptions.additionalMenuItems || undefined;
const additionalSubMenuItems = panelSpecificMenuOptions.additionalSubMenuItems || undefined; const additionalSubMenuItems = panelSpecificMenuOptions.additionalSubMenuItems || undefined;
......
...@@ -4,8 +4,8 @@ import { PanelModel } from 'app/features/dashboard/panel_model'; ...@@ -4,8 +4,8 @@ import { PanelModel } from 'app/features/dashboard/panel_model';
import { PanelHeaderMenuItem } from './PanelHeaderMenuItem'; import { PanelHeaderMenuItem } from './PanelHeaderMenuItem';
import { PanelHeaderMenuItemProps } from 'app/types/panel'; import { PanelHeaderMenuItemProps } from 'app/types/panel';
import { getPanelMenu } from 'app/features/dashboard/utils/panel_menu'; import { getPanelMenu } from 'app/features/dashboard/utils/panel_menu';
import { DataSourceApi } from 'app/types/series';
import { TimeSeries } from 'app/types'; import { TimeSeries } from 'app/types';
import { DataSourceApi } from 'app/types/series';
export interface PanelHeaderMenuProps { export interface PanelHeaderMenuProps {
panel: PanelModel; panel: PanelModel;
......
...@@ -7,8 +7,6 @@ import { Switch } from 'app/core/components/Switch/Switch'; ...@@ -7,8 +7,6 @@ import { Switch } from 'app/core/components/Switch/Switch';
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries'; import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
import { PanelProps, PanelOptionsProps, NullValueMode } from 'app/types'; import { PanelProps, PanelOptionsProps, NullValueMode } from 'app/types';
// import { moduleMenu } from './moduleMenu';
interface Options { interface Options {
showBars: boolean; showBars: boolean;
showLines: boolean; showLines: boolean;
...@@ -75,4 +73,4 @@ export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> { ...@@ -75,4 +73,4 @@ export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
} }
export { Graph2 as PanelComponent, GraphOptions as PanelOptionsComponent }; export { Graph2 as PanelComponent, GraphOptions as PanelOptionsComponent };
export { moduleMenu } from './moduleMenu'; export { getMenuAdditional } from './moduleMenu';
...@@ -7,8 +7,11 @@ import { store } from 'app/store/configureStore'; ...@@ -7,8 +7,11 @@ import { store } from 'app/store/configureStore';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import { PanelHeaderMenuItemProps, PanelHeaderMenuItemTypes } from 'app/types/panel'; import { PanelHeaderMenuItemProps, PanelHeaderMenuItemTypes } from 'app/types/panel';
import { TimeSeries } from 'app/types/series';
import { DataSource } from 'app/types/datasources';
import { PanelModel } from 'app/features/dashboard/panel_model';
export const moduleMenu = (panel, dataSourceApi, timeSeries) => { export const getMenuAdditional = (panel: PanelModel, dataSourceApi: DataSource, timeSeries: TimeSeries[]) => {
const onExploreClick = async () => { const onExploreClick = async () => {
const datasourceSrv = getDatasourceSrv(); const datasourceSrv = getDatasourceSrv();
const timeSrv = getTimeSrv(); const timeSrv = getTimeSrv();
...@@ -19,7 +22,7 @@ export const moduleMenu = (panel, dataSourceApi, timeSeries) => { ...@@ -19,7 +22,7 @@ export const moduleMenu = (panel, dataSourceApi, timeSeries) => {
}; };
const onExportCsv = () => { const onExportCsv = () => {
const model = {} as { seriesList: string }; const model = {} as { seriesList: TimeSeries[] };
model.seriesList = timeSeries; model.seriesList = timeSeries;
appEvents.emit('show-modal', { appEvents.emit('show-modal', {
templateHtml: '<export-data-modal data="model.seriesList"></export-data-modal>', templateHtml: '<export-data-modal data="model.seriesList"></export-data-modal>',
......
import { LoadingState, TimeSeries, TimeRange } from './series'; import { LoadingState, TimeSeries, TimeRange, DataSourceApi } from './series';
import { PanelModel } from 'app/features/dashboard/panel_model';
export interface PanelProps<T = any> { export interface PanelProps<T = any> {
timeSeries: TimeSeries[]; timeSeries: TimeSeries[];
...@@ -31,7 +32,11 @@ export interface PanelHeaderMenuItemProps { ...@@ -31,7 +32,11 @@ export interface PanelHeaderMenuItemProps {
role?: string; role?: string;
} }
export interface PanelMenuExtras { export interface PanelHeaderMenuAdditional {
additionalMenuItems: PanelHeaderMenuItemProps[]; additionalMenuItems: PanelHeaderMenuItemProps[];
additionalSubMenuItems: PanelHeaderMenuItemProps[]; additionalSubMenuItems: PanelHeaderMenuItemProps[];
} }
export interface PanelHeaderGetMenuAdditional {
(panel: PanelModel, dataSourceApi: DataSourceApi, timeSeries: TimeSeries[]): PanelHeaderMenuAdditional;
}
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { PanelProps, PanelOptionsProps } from './panel'; import { PanelProps, PanelOptionsProps } from './panel';
import { PanelHeaderGetMenuAdditional } from 'app/types/panel';
export interface PluginExports { export interface PluginExports {
Datasource?: any; Datasource?: any;
...@@ -13,7 +14,7 @@ export interface PluginExports { ...@@ -13,7 +14,7 @@ export interface PluginExports {
PanelCtrl?; PanelCtrl?;
PanelComponent?: ComponentClass<PanelProps>; PanelComponent?: ComponentClass<PanelProps>;
PanelOptionsComponent: ComponentClass<PanelOptionsProps>; PanelOptionsComponent: ComponentClass<PanelOptionsProps>;
moduleMenu?: any; getMenuAdditional?: PanelHeaderGetMenuAdditional;
} }
export interface PanelPlugin { export interface PanelPlugin {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment