mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: Add "Share" to the react panels
This commit is contained in:
parent
bf8703edb8
commit
839057dc7a
@ -4,6 +4,7 @@ import { PanelHeaderMenuItem, PanelHeaderMenuItemTypes } from './PanelHeaderMenu
|
|||||||
import { store } from 'app/store/configureStore';
|
import { store } from 'app/store/configureStore';
|
||||||
import { updateLocation } from 'app/core/actions';
|
import { updateLocation } from 'app/core/actions';
|
||||||
import { removePanel } from 'app/features/dashboard/utils/panel';
|
import { removePanel } from 'app/features/dashboard/utils/panel';
|
||||||
|
import appEvents from 'app/core/app_events';
|
||||||
|
|
||||||
export interface PanelHeaderMenuProps {
|
export interface PanelHeaderMenuProps {
|
||||||
panelId: number;
|
panelId: number;
|
||||||
@ -11,6 +12,13 @@ export interface PanelHeaderMenuProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
|
export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
|
||||||
|
getPanel = () => {
|
||||||
|
// Pass in panel as prop instead?
|
||||||
|
const { panelId, dashboard } = this.props;
|
||||||
|
const panelInfo = dashboard.getPanelInfoById(panelId);
|
||||||
|
return panelInfo.panel;
|
||||||
|
};
|
||||||
|
|
||||||
onEditPanel = () => {
|
onEditPanel = () => {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
updateLocation({
|
updateLocation({
|
||||||
@ -36,9 +44,22 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onRemovePanel = () => {
|
onRemovePanel = () => {
|
||||||
const { panelId, dashboard } = this.props;
|
const { dashboard } = this.props;
|
||||||
const panelInfo = dashboard.getPanelInfoById(panelId);
|
const panel = this.getPanel();
|
||||||
removePanel(dashboard, panelInfo.panel, true);
|
removePanel(dashboard, panel, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
onSharePanel = () => {
|
||||||
|
const { dashboard } = this.props;
|
||||||
|
const panel = this.getPanel();
|
||||||
|
|
||||||
|
appEvents.emit('show-modal', {
|
||||||
|
src: 'public/app/features/dashboard/partials/shareModal.html',
|
||||||
|
model: {
|
||||||
|
panel: panel,
|
||||||
|
dashboard: dashboard,
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -63,7 +84,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
|
|||||||
type={PanelHeaderMenuItemTypes.Link}
|
type={PanelHeaderMenuItemTypes.Link}
|
||||||
text="Share"
|
text="Share"
|
||||||
iconClassName="fa fa-fw fa-share"
|
iconClassName="fa fa-fw fa-share"
|
||||||
handleClick={() => {}}
|
handleClick={this.onSharePanel}
|
||||||
shortcut="p s"
|
shortcut="p s"
|
||||||
/>
|
/>
|
||||||
<PanelHeaderMenuItem
|
<PanelHeaderMenuItem
|
||||||
|
Loading…
Reference in New Issue
Block a user