mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: panel-header: Refactor so "Share" use the same code in angular+react
This commit is contained in:
parent
f9dd516578
commit
5375ce5ffd
@ -3,8 +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, duplicatePanel, copyPanel, editPanelJson } from 'app/features/dashboard/utils/panel';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { removePanel, duplicatePanel, copyPanel, editPanelJson, sharePanel } from 'app/features/dashboard/utils/panel';
|
||||
|
||||
export interface PanelHeaderMenuProps {
|
||||
panelId: number;
|
||||
@ -53,13 +52,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
|
||||
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,
|
||||
},
|
||||
});
|
||||
sharePanel(dashboard, panel);
|
||||
};
|
||||
|
||||
onDuplicatePanel = () => {
|
||||
|
@ -12,6 +12,8 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
|
||||
$scope.editor = { index: $scope.tabIndex || 0 };
|
||||
|
||||
$scope.init = () => {
|
||||
$scope.panel = $scope.model.panel || $scope.panel; // React pass panel and dashboard in the "model" property
|
||||
$scope.dashboard = $scope.model.dashboard || $scope.dashboard;
|
||||
$scope.modeSharePanel = $scope.panel ? true : false;
|
||||
|
||||
$scope.tabs = [{ title: 'Link', src: 'shareLink.html' }];
|
||||
|
@ -63,3 +63,13 @@ export const editPanelJson = (dashboard: DashboardModel, panel: PanelModel) => {
|
||||
model: model,
|
||||
});
|
||||
};
|
||||
|
||||
export const sharePanel = (dashboard: DashboardModel, panel: PanelModel) => {
|
||||
appEvents.emit('show-modal', {
|
||||
src: 'public/app/features/dashboard/partials/shareModal.html',
|
||||
model: {
|
||||
dashboard: dashboard,
|
||||
panel: panel,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
duplicatePanel,
|
||||
copyPanel as copyPanelUtil,
|
||||
editPanelJson as editPanelJsonUtil,
|
||||
sharePanel as sharePanelUtil,
|
||||
} from 'app/features/dashboard/utils/panel';
|
||||
import Remarkable from 'remarkable';
|
||||
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
|
||||
@ -262,14 +263,7 @@ export class PanelCtrl {
|
||||
}
|
||||
|
||||
sharePanel() {
|
||||
const shareScope = this.$scope.$new();
|
||||
shareScope.panel = this.panel;
|
||||
shareScope.dashboard = this.dashboard;
|
||||
|
||||
this.publishAppEvent('show-modal', {
|
||||
src: 'public/app/features/dashboard/partials/shareModal.html',
|
||||
scope: shareScope,
|
||||
});
|
||||
sharePanelUtil(this.dashboard, this.panel);
|
||||
}
|
||||
|
||||
getInfoMode() {
|
||||
|
Loading…
Reference in New Issue
Block a user