From 908765e0e777e50c4b84a0075bc1f278c20b5751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 3 Feb 2016 18:49:36 +0100 Subject: [PATCH] feat(plugins): various fixes entering edit mode after adding a new panel --- public/app/features/dashboard/viewStateSrv.js | 5 +++++ .../app/features/panel/metrics_panel_ctrl.ts | 1 + public/app/features/panel/panel_ctrl.ts | 20 ++++++++----------- public/app/plugins/panel/singlestat/module.ts | 2 ++ public/app/plugins/panel/table/controller.ts | 2 +- public/app/plugins/panel/text/module.ts | 2 ++ 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/public/app/features/dashboard/viewStateSrv.js b/public/app/features/dashboard/viewStateSrv.js index abe1ec3279e..b18610d7c1d 100644 --- a/public/app/features/dashboard/viewStateSrv.js +++ b/public/app/features/dashboard/viewStateSrv.js @@ -103,6 +103,11 @@ function (angular, _, $) { if (!panelScope) { return; } + + if (!panelScope.ctrl.editModeInitiated) { + panelScope.ctrl.initEditMode(); + } + this.enterFullscreen(panelScope); return; } diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 47f2393c4c0..c56b900b59c 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -41,6 +41,7 @@ class MetricsPanelCtrl extends PanelCtrl { } initEditMode() { + super.initEditMode(); this.addEditorTab('Metrics', 'public/app/partials/metrics.html'); this.addEditorTab('Time range', 'public/app/features/panel/partials/panelTime.html'); this.datasources = this.datasourceSrv.getMetricSources(); diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index fa1b8663f9c..175fba2e5f9 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -63,12 +63,6 @@ export class PanelCtrl { } editPanel() { - if (!this.editModeInitiated) { - this.editorTabs = []; - this.addEditorTab('General', 'public/app/partials/panelgeneral.html'); - this.initEditMode(); - } - this.changeView(true, true); } @@ -77,7 +71,9 @@ export class PanelCtrl { } initEditMode() { - return; + this.editorTabs = []; + this.addEditorTab('General', 'public/app/partials/panelgeneral.html'); + this.editModeInitiated = true; } addEditorTab(title, directiveFn, index?) { @@ -166,12 +162,12 @@ export class PanelCtrl { }); } - sharePanel() { - var shareScope = this.$scope.$new(); - shareScope.panel = this.panel; - shareScope.dashboard = this.dashboard; + sharePanel() { + var shareScope = this.$scope.$new(); + shareScope.panel = this.panel; + shareScope.dashboard = this.dashboard; - this.publishAppEvent('show-modal', { + this.publishAppEvent('show-modal', { src: 'public/app/features/dashboard/partials/shareModal.html', scope: shareScope }); diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index ca892a59daf..e0ea4429b39 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -32,6 +32,8 @@ class SingleStatPanel extends PanelDirective { $panelContainer = elem.parents('.panel-container'); firstRender = false; hookupDrilldownLinkTooltip(); + } else { + return; } } diff --git a/public/app/plugins/panel/table/controller.ts b/public/app/plugins/panel/table/controller.ts index 1fa11d83858..a526a8a8798 100644 --- a/public/app/plugins/panel/table/controller.ts +++ b/public/app/plugins/panel/table/controller.ts @@ -57,7 +57,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { initEditMode() { super.initEditMode(); - this.addEditorTab('Options', tablePanelEditor, 1); + this.addEditorTab('Options', tablePanelEditor, 2); } getExtendedMenu() { diff --git a/public/app/plugins/panel/text/module.ts b/public/app/plugins/panel/text/module.ts index 3db30d1b43e..08dbb9d388b 100644 --- a/public/app/plugins/panel/text/module.ts +++ b/public/app/plugins/panel/text/module.ts @@ -21,8 +21,10 @@ export class TextPanelCtrl extends PanelCtrl { } initEditMode() { + super.initEditMode(); this.icon = 'fa fa-text-width'; this.addEditorTab('Options', 'public/app/plugins/panel/text/editor.html'); + this.editorTabIndex = 1; } refresh() {