Commit a9bf8f80 by Torkel Ödegaard Committed by GitHub

Search: Fixed angular digest issues (#20906)

parent 9d9f0e1b
import { IScope } from 'angular';
import _ from 'lodash';
import coreModule from 'app/core/core_module';
import appEvents from 'app/core/app_events';
import { SearchSrv } from 'app/core/services/search_srv';
import { BackendSrv } from 'app/core/services/backend_srv';
import { NavModelSrv } from 'app/core/nav_model_srv';
import { ContextSrv } from 'app/core/services/context_srv';
import { CoreEvents } from 'app/types';
......@@ -70,8 +70,8 @@ export class ManageDashboardsCtrl {
/** @ngInject */
constructor(
private $scope: IScope,
private backendSrv: BackendSrv,
navModelSrv: NavModelSrv,
private searchSrv: SearchSrv,
private contextSrv: ContextSrv
) {
......@@ -107,6 +107,7 @@ export class ManageDashboardsCtrl {
})
.then(() => {
if (!this.folderUid) {
this.$scope.$digest();
return;
}
......@@ -115,6 +116,7 @@ export class ManageDashboardsCtrl {
if (!this.canSave) {
this.hasEditPermissionInFolders = false;
}
this.$scope.$digest();
});
});
}
......
......@@ -60,7 +60,7 @@ export class SearchCtrl {
queryParser: SearchQueryParser;
/** @ngInject */
constructor($scope: any, private $location: any, private $timeout: any, private searchSrv: SearchSrv) {
constructor(private $scope: any, private $location: any, private $timeout: any, private searchSrv: SearchSrv) {
appEvents.on(CoreEvents.showDashSearch, this.openSearch.bind(this), $scope);
appEvents.on(CoreEvents.hideDashSearch, this.closeSearch.bind(this), $scope);
appEvents.on(CoreEvents.searchQuery, debounce(this.search.bind(this), 500), $scope);
......@@ -252,6 +252,7 @@ export class SearchCtrl {
this.results = results || [];
this.isLoading = false;
this.moveSelection(1);
this.$scope.$digest();
});
}
......
......@@ -7,7 +7,6 @@ import {
} from 'app/core/components/manage_dashboards/manage_dashboards';
import { SearchSrv } from 'app/core/services/search_srv';
import { BackendSrv } from '../services/backend_srv';
import { NavModelSrv } from '../nav_model_srv';
import { ContextSrv } from '../services/context_srv';
const mockSection = (overides?: object): Section => {
......@@ -593,8 +592,8 @@ function createCtrlWithStubs(searchResponse: any, tags?: any) {
};
return new ManageDashboardsCtrl(
{ $digest: jest.fn() } as any,
{} as BackendSrv,
{ getNav: () => {} } as NavModelSrv,
searchSrvStub as SearchSrv,
{ isEditor: true } as ContextSrv
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment