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 { PanelHeaderMenuItem, PanelHeaderMenuItemTypes } from './PanelHeaderMenuItem';
|
||||||
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, duplicatePanel, copyPanel, editPanelJson } from 'app/features/dashboard/utils/panel';
|
import { removePanel, duplicatePanel, copyPanel, editPanelJson, sharePanel } from 'app/features/dashboard/utils/panel';
|
||||||
import appEvents from 'app/core/app_events';
|
|
||||||
|
|
||||||
export interface PanelHeaderMenuProps {
|
export interface PanelHeaderMenuProps {
|
||||||
panelId: number;
|
panelId: number;
|
||||||
@ -53,13 +52,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
|
|||||||
const { dashboard } = this.props;
|
const { dashboard } = this.props;
|
||||||
const panel = this.getPanel();
|
const panel = this.getPanel();
|
||||||
|
|
||||||
appEvents.emit('show-modal', {
|
sharePanel(dashboard, panel);
|
||||||
src: 'public/app/features/dashboard/partials/shareModal.html',
|
|
||||||
model: {
|
|
||||||
panel: panel,
|
|
||||||
dashboard: dashboard,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onDuplicatePanel = () => {
|
onDuplicatePanel = () => {
|
||||||
|
@ -12,6 +12,8 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
|
|||||||
$scope.editor = { index: $scope.tabIndex || 0 };
|
$scope.editor = { index: $scope.tabIndex || 0 };
|
||||||
|
|
||||||
$scope.init = () => {
|
$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.modeSharePanel = $scope.panel ? true : false;
|
||||||
|
|
||||||
$scope.tabs = [{ title: 'Link', src: 'shareLink.html' }];
|
$scope.tabs = [{ title: 'Link', src: 'shareLink.html' }];
|
||||||
|
@ -63,3 +63,13 @@ export const editPanelJson = (dashboard: DashboardModel, panel: PanelModel) => {
|
|||||||
model: model,
|
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,
|
duplicatePanel,
|
||||||
copyPanel as copyPanelUtil,
|
copyPanel as copyPanelUtil,
|
||||||
editPanelJson as editPanelJsonUtil,
|
editPanelJson as editPanelJsonUtil,
|
||||||
|
sharePanel as sharePanelUtil,
|
||||||
} from 'app/features/dashboard/utils/panel';
|
} from 'app/features/dashboard/utils/panel';
|
||||||
import Remarkable from 'remarkable';
|
import Remarkable from 'remarkable';
|
||||||
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
|
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
|
||||||
@ -262,14 +263,7 @@ export class PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sharePanel() {
|
sharePanel() {
|
||||||
const shareScope = this.$scope.$new();
|
sharePanelUtil(this.dashboard, this.panel);
|
||||||
shareScope.panel = this.panel;
|
|
||||||
shareScope.dashboard = this.dashboard;
|
|
||||||
|
|
||||||
this.publishAppEvent('show-modal', {
|
|
||||||
src: 'public/app/features/dashboard/partials/shareModal.html',
|
|
||||||
scope: shareScope,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getInfoMode() {
|
getInfoMode() {
|
||||||
|
Loading…
Reference in New Issue
Block a user