瀏覽代碼

Fix save as dashboard from folder to General folder (#10988)

* dashboards: fix save as dashboard from folder to general folder

* dashboards: disable save button in save dashboard as dialog when creating a new folder
Marcus Efraimsson 7 年之前
父節點
當前提交
bb7a6718f1
共有 2 個文件被更改,包括 13 次插入2 次删除
  1. 1 1
      public/app/features/dashboard/dashboard_srv.ts
  2. 12 1
      public/app/features/dashboard/save_as_modal.ts

+ 1 - 1
public/app/features/dashboard/dashboard_srv.ts

@@ -92,7 +92,7 @@ export class DashboardSrv {
 
 
   save(clone, options) {
   save(clone, options) {
     options = options || {};
     options = options || {};
-    options.folderId = options.folderId || this.dash.meta.folderId || clone.folderId;
+    options.folderId = options.folderId >= 0 ? options.folderId : this.dash.meta.folderId || clone.folderId;
 
 
     return this.backendSrv
     return this.backendSrv
       .saveDashboard(clone, options)
       .saveDashboard(clone, options)

+ 12 - 1
public/app/features/dashboard/save_as_modal.ts

@@ -22,6 +22,8 @@ const template = `
       <div class="gf-form">
       <div class="gf-form">
         <folder-picker initial-folder-id="ctrl.folderId"
         <folder-picker initial-folder-id="ctrl.folderId"
                        on-change="ctrl.onFolderChange($folder)"
                        on-change="ctrl.onFolderChange($folder)"
+                       enter-folder-creation="ctrl.onEnterFolderCreation()"
+                       exit-folder-creation="ctrl.onExitFolderCreation()"
                        enable-create-new="true"
                        enable-create-new="true"
                        label-class="width-7">
                        label-class="width-7">
         </folder-picker>
         </folder-picker>
@@ -29,7 +31,7 @@ const template = `
 		</div>
 		</div>
 
 
 		<div class="gf-form-button-row text-center">
 		<div class="gf-form-button-row text-center">
-			<button type="submit" class="btn btn-success" ng-click="ctrl.save()">Save</button>
+			<button type="submit" class="btn btn-success" ng-click="ctrl.save()" ng-disabled="!ctrl.isValidFolderSelection">Save</button>
 			<a class="btn-text" ng-click="ctrl.dismiss();">Cancel</a>
 			<a class="btn-text" ng-click="ctrl.dismiss();">Cancel</a>
 		</div>
 		</div>
 	</form>
 	</form>
@@ -40,6 +42,7 @@ export class SaveDashboardAsModalCtrl {
   clone: any;
   clone: any;
   folderId: any;
   folderId: any;
   dismiss: () => void;
   dismiss: () => void;
+  isValidFolderSelection = true;
 
 
   /** @ngInject */
   /** @ngInject */
   constructor(private dashboardSrv) {
   constructor(private dashboardSrv) {
@@ -79,6 +82,14 @@ export class SaveDashboardAsModalCtrl {
   onFolderChange(folder) {
   onFolderChange(folder) {
     this.folderId = folder.id;
     this.folderId = folder.id;
   }
   }
+
+  onEnterFolderCreation() {
+    this.isValidFolderSelection = false;
+  }
+
+  onExitFolderCreation() {
+    this.isValidFolderSelection = true;
+  }
 }
 }
 
 
 export function saveDashboardAsDirective() {
 export function saveDashboardAsDirective() {