mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: panel-header: Add "Duplicate"
This commit is contained in:
@@ -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={() => {}} />
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user