Files
Hugo Häggmark 841cffbe9a e2e: Migrates query variable CRUD tests to new framework (#21146)
* Refactor: Adds params to visit

* Refactor: Restructures exported Pages somewhat

* Refactor: Moves more into new framework but holdup because of bugs in digest

* Refactor: Finish migrating templating e2e tests to new framework

* Refactor: Changes after merge with master

* Refactor: Removes weird change

* Refactor: Adds duplication test

* Refactor: Adds move down and move up variable asserts

* Refactor: Adds some test to value select dropdown
2019-12-18 06:13:58 +01:00

53 lines
1.5 KiB
TypeScript

import angular, { ILocationService } from 'angular';
import _ from 'lodash';
import { e2e } from '@grafana/e2e';
import { VariableSrv } from 'app/features/templating/all';
import { CoreEvents } from '../../../../types';
export class SubMenuCtrl {
annotations: any;
variables: any;
dashboard: any;
submenuEnabled: boolean;
selectors: typeof e2e.pages.Dashboard.SubMenu.selectors;
/** @ngInject */
constructor(private variableSrv: VariableSrv, private $location: ILocationService) {
this.annotations = this.dashboard.templating.list;
this.variables = this.variableSrv.variables;
this.submenuEnabled = this.dashboard.meta.submenuEnabled;
this.dashboard.events.on(CoreEvents.submenuVisibilityChanged, (enabled: boolean) => {
this.submenuEnabled = enabled;
});
this.selectors = e2e.pages.Dashboard.SubMenu.selectors;
}
annotationStateChanged() {
this.dashboard.startRefresh();
}
variableUpdated(variable: any) {
this.variableSrv.variableUpdated(variable, true);
}
openEditView(editview: any) {
const search = _.extend(this.$location.search(), { editview: editview });
this.$location.search(search);
}
}
export function submenuDirective() {
return {
restrict: 'E',
templateUrl: 'public/app/features/dashboard/components/SubMenu/template.html',
controller: SubMenuCtrl,
bindToController: true,
controllerAs: 'ctrl',
scope: {
dashboard: '=',
},
};
}
angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective);