wip: panel-header: Add "Duplicate"

This commit is contained in:
Johannes Schill
2018-10-30 14:38:18 +01:00
parent 839057dc7a
commit b296d724e5
3 changed files with 16 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ import { DashboardModel } from 'app/features/dashboard/dashboard_model';
import { PanelHeaderMenuItem, PanelHeaderMenuItemTypes } from './PanelHeaderMenuItem';
import { store } from 'app/store/configureStore';
import { updateLocation } from 'app/core/actions';
import { removePanel } from 'app/features/dashboard/utils/panel';
import { removePanel, duplicatePanel } from 'app/features/dashboard/utils/panel';
import appEvents from 'app/core/app_events';
export interface PanelHeaderMenuProps {
@@ -62,6 +62,13 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
});
};
onDuplicatePanel = () => {
const { dashboard } = this.props;
const panel = this.getPanel();
duplicatePanel(dashboard, panel);
};
render() {
return (
<div className="panel-menu-container dropdown">
@@ -98,7 +105,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
type={PanelHeaderMenuItemTypes.Link}
text="Duplicate"
iconClassName=""
handleClick={() => {}}
handleClick={this.onDuplicatePanel}
shortcut="p d"
/>
<PanelHeaderMenuItem type={PanelHeaderMenuItemTypes.Link} text="Copy" handleClick={() => {}} />

View File

@@ -22,6 +22,11 @@ export const removePanel = (dashboard: DashboardModel, panel: PanelModel, ask: b
dashboard.removePanel(panel);
};
export const duplicatePanel = (dashboard: DashboardModel, panel: PanelModel) => {
dashboard.duplicatePanel(panel);
};
export default {
removePanel,
duplicatePanel,
};

View File

@@ -3,6 +3,7 @@ import _ from 'lodash';
import $ from 'jquery';
import { appEvents, profiler } from 'app/core/core';
import { PanelModel } from 'app/features/dashboard/panel_model';
import { duplicatePanel } from 'app/features/dashboard/utils/panel';
import Remarkable from 'remarkable';
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, LS_PANEL_COPY_KEY } from 'app/core/constants';
import store from 'app/core/store';
@@ -241,7 +242,7 @@ export class PanelCtrl {
}
duplicate() {
this.dashboard.duplicatePanel(this.panel);
duplicatePanel(this.dashboard, this.panel);
}
removePanel() {