diff --git a/public/app/core/components/search/search.ts b/public/app/core/components/search/search.ts
index dcbf0991f3d..69c3584ad52 100644
--- a/public/app/core/components/search/search.ts
+++ b/public/app/core/components/search/search.ts
@@ -42,7 +42,7 @@ export class SearchCtrl {
this.giveSearchFocus = 0;
this.selectedIndex = -1;
this.results = [];
- this.query = { query: '', tag: [], starred: false };
+ this.query = { query: '', tag: [], starred: false, mode: 'tree' };
this.currentSearchId = 0;
this.ignoreClose = true;
diff --git a/public/app/features/dashboard/dashnav/dashnav.ts b/public/app/features/dashboard/dashnav/dashnav.ts
index e77c2bb3e09..25dd51494cf 100644
--- a/public/app/features/dashboard/dashnav/dashnav.ts
+++ b/public/app/features/dashboard/dashnav/dashnav.ts
@@ -135,6 +135,10 @@ export class DashNavCtrl {
var uri = "data:application/json;charset=utf-8," + encodeURIComponent(html);
var newWindow = window.open(uri);
}
+
+ onFolderChange(parentId) {
+ this.dashboard.parentId = parentId;
+ }
}
export function dashNavDirective() {
diff --git a/public/app/features/dashboard/folder_picker/picker.ts b/public/app/features/dashboard/folder_picker/picker.ts
index 92ded3a5256..a378ac18b12 100644
--- a/public/app/features/dashboard/folder_picker/picker.ts
+++ b/public/app/features/dashboard/folder_picker/picker.ts
@@ -5,32 +5,34 @@ import appEvents from 'app/core/app_events';
import _ from 'lodash';
export class FolderPickerCtrl {
- dashboard: any;
folders: Folder[];
selectedFolder: number;
selectedFolderSegment: any;
+ onChange: any;
+ rootFolderName: string;
/** @ngInject */
constructor(private backendSrv, private $scope, private $sce, private uiSegmentSrv) {
- this.selectedFolderSegment = this.uiSegmentSrv.newSegment({value: 'Root', selectMode: true});
-
- this.selectedFolder = this.dashboard.meta.parentId;
- this.get(this.dashboard.id);
+ this.selectedFolderSegment = this.uiSegmentSrv.newSegment({value: this.rootFolderName || 'Root', selectMode: true});
+ this.get();
}
- get(dashboardId: number) {
+ get() {
var params = {
type: 'dash-folder',
};
return this.backendSrv.search(params).then(result => {
- this.folders = [{id: 0, title: 'Root', type: 'dash-folder'}];
+ this.folders = [{id: 0, title: this.rootFolderName || 'Root', type: 'dash-folder'}];
this.folders.push(...result);
- const selected = _.find(this.folders, {id: this.selectedFolder});
- this.selectedFolderSegment.value = selected.title;
- this.selectedFolderSegment.text = selected.title;
- this.selectedFolderSegment.html = this.$sce.trustAsHtml(selected.title);
+ if (this.selectedFolder) {
+ const selected = _.find(this.folders, {id: this.selectedFolder});
+
+ this.selectedFolderSegment.value = selected.title;
+ this.selectedFolderSegment.text = selected.title;
+ this.selectedFolderSegment.html = this.$sce.trustAsHtml(selected.title);
+ }
});
}
@@ -43,7 +45,7 @@ export class FolderPickerCtrl {
folderChanged() {
const selected = _.find(this.folders, {title: this.selectedFolderSegment.value});
if (selected) {
- this.dashboard.parentId = selected.id;
+ this.onChange(selected.id);
}
}
}
@@ -66,7 +68,11 @@ export function folderPicker() {
controller: FolderPickerCtrl,
bindToController: true,
controllerAs: 'ctrl',
- scope: { dashboard: "=" }
+ scope: {
+ selectedFolder: "<",
+ onChange: "<",
+ rootFolderName: "@"
+ }
};
}
diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html
index b2e9b6bfd76..6ff00f4cf59 100644
--- a/public/app/features/dashboard/partials/settings.html
+++ b/public/app/features/dashboard/partials/settings.html
@@ -45,7 +45,7 @@
-