2018-10-25 07:29:03 -05:00
|
|
|
|
import appEvents from 'app/core/app_events';
|
|
|
|
|
import { DashboardModel } from 'app/features/dashboard/dashboard_model';
|
|
|
|
|
import { PanelModel } from 'app/features/dashboard/panel_model';
|
|
|
|
|
|
|
|
|
|
export const removePanel = (dashboard: DashboardModel, panel: PanelModel, ask: boolean) => {
|
|
|
|
|
// confirm deletion
|
|
|
|
|
if (ask !== false) {
|
|
|
|
|
const text2 = panel.alert ? 'Panel includes an alert rule, removing panel will also remove alert rule' : null;
|
|
|
|
|
const confirmText = panel.alert ? 'YES' : null;
|
|
|
|
|
|
|
|
|
|
appEvents.emit('confirm-modal', {
|
|
|
|
|
title: 'Remove Panel',
|
|
|
|
|
text: 'Are you sure you want to remove this panel?',
|
|
|
|
|
text2: text2,
|
|
|
|
|
icon: 'fa-trash',
|
|
|
|
|
confirmText: confirmText,
|
|
|
|
|
yesText: 'Remove',
|
|
|
|
|
onConfirm: () => removePanel(dashboard, panel, false),
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dashboard.removePanel(panel);
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-30 08:38:18 -05:00
|
|
|
|
export const duplicatePanel = (dashboard: DashboardModel, panel: PanelModel) => {
|
|
|
|
|
dashboard.duplicatePanel(panel);
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-25 07:29:03 -05:00
|
|
|
|
export default {
|
|
|
|
|
removePanel,
|
2018-10-30 08:38:18 -05:00
|
|
|
|
duplicatePanel,
|
2018-10-25 07:29:03 -05:00
|
|
|
|
};
|