diff --git a/src/app/features/annotations/editorCtrl.js b/src/app/features/annotations/editorCtrl.js index 9b6da497dce..b61dd6b05e4 100644 --- a/src/app/features/annotations/editorCtrl.js +++ b/src/app/features/annotations/editorCtrl.js @@ -64,11 +64,13 @@ function (angular, _, $) { $scope.annotations.push($scope.currentAnnotation); $scope.reset(); $scope.editor.index = 0; + $scope.updateSubmenuVisibility(); }; $scope.removeAnnotation = function(annotation) { var index = _.indexOf($scope.annotations, annotation); $scope.annotations.splice(index, 1); + $scope.updateSubmenuVisibility(); }; }); diff --git a/src/app/features/dashboard/dashboardCtrl.js b/src/app/features/dashboard/dashboardCtrl.js index 712998c6a45..facd5fada43 100644 --- a/src/app/features/dashboard/dashboardCtrl.js +++ b/src/app/features/dashboard/dashboardCtrl.js @@ -51,14 +51,18 @@ function (angular, $, config) { timeSrv.init($scope.dashboard); templateValuesSrv.init($scope.dashboard, $scope.dashboardViewState); - $scope.checkFeatureToggles(); dashboardKeybindings.shortcuts($scope); + $scope.updateSubmenuVisibility(); $scope.setWindowTitleAndTheme(); $scope.appEvent("dashboard-loaded", $scope.dashboard); }; + $scope.updateSubmenuVisibility = function() { + $scope.submenuEnabled = $scope.dashboard.hasTemplateVarsOrAnnotations(); + }; + $scope.setWindowTitleAndTheme = function() { window.document.title = config.window_title_prefix + $scope.dashboard.title; $scope.contextSrv.lightTheme = $scope.dashboard.style === 'light'; @@ -101,10 +105,6 @@ function (angular, $, config) { $scope.appEvent('show-dash-editor', { src: 'app/partials/edit_json.html', scope: editScope }); }; - $scope.checkFeatureToggles = function() { - $scope.submenuEnabled = $scope.dashboard.templating.enable || $scope.dashboard.annotations.enable || false; - }; - $scope.onDrop = function(panelId, row, dropTarget) { var info = $scope.dashboard.getPanelInfoById(panelId); if (dropTarget) { diff --git a/src/app/features/dashboard/dashboardSrv.js b/src/app/features/dashboard/dashboardSrv.js index 94448265cca..8a41ddee5d8 100644 --- a/src/app/features/dashboard/dashboardSrv.js +++ b/src/app/features/dashboard/dashboardSrv.js @@ -91,6 +91,10 @@ function (angular, $, kbn, _, moment) { row.panels.push(panel); }; + p.hasTemplateVarsOrAnnotations = function() { + return this.templating.list.length > 0 || this.annotations.list.length > 0; + }; + p.getPanelInfoById = function(panelId) { var result = {}; _.each(this.rows, function(row) { @@ -215,15 +219,11 @@ function (angular, $, kbn, _, moment) { if (oldVersion < 6) { // move pulldowns to new schema - var filtering = _.findWhere(old.pulldowns, { type: 'filtering' }); var annotations = _.findWhere(old.pulldowns, { type: 'annotations' }); - if (filtering) { - this.templating.enable = filtering.enable; - } + if (annotations) { this.annotations = { - list: annotations.annotations, - enable: annotations.enable + list: annotations.annotations || [], }; } diff --git a/src/app/features/dashboard/submenuCtrl.js b/src/app/features/dashboard/submenuCtrl.js index bf71377dd14..456cc1b76c1 100644 --- a/src/app/features/dashboard/submenuCtrl.js +++ b/src/app/features/dashboard/submenuCtrl.js @@ -18,6 +18,7 @@ function (angular, _) { $scope.panel = $scope.pulldown; $scope.row = $scope.pulldown; $scope.variables = $scope.dashboard.templating.list; + $scope.annotations = $scope.dashboard.templating.list; }; $scope.disableAnnotation = function (annotation) { diff --git a/src/app/features/templating/editorCtrl.js b/src/app/features/templating/editorCtrl.js index 51b5d7c9e38..f17c383155d 100644 --- a/src/app/features/templating/editorCtrl.js +++ b/src/app/features/templating/editorCtrl.js @@ -36,6 +36,7 @@ function (angular, _) { if ($scope.isValid()) { $scope.variables.push($scope.current); $scope.update(); + $scope.updateSubmenuVisibility(); } }; @@ -104,6 +105,7 @@ function (angular, _) { $scope.removeVariable = function(variable) { var index = _.indexOf($scope.variables, variable); $scope.variables.splice(index, 1); + $scope.updateSubmenuVisibility(); }; }); diff --git a/src/app/partials/dasheditor.html b/src/app/partials/dasheditor.html index 4d7d372d22b..843f73b24db 100644 --- a/src/app/partials/dasheditor.html +++ b/src/app/partials/dasheditor.html @@ -5,7 +5,7 @@