Преглед изворни кода

dashlist: When searching should reset checked state to false

Marcus Efraimsson пре 8 година
родитељ
комит
7ee57b774a

+ 7 - 0
public/app/features/dashboard/dashboard_list_ctrl.ts

@@ -39,6 +39,9 @@ export class DashboardListCtrl {
   }
   }
 
 
   initDashboardList(result: any) {
   initDashboardList(result: any) {
+    this.canMove = false;
+    this.canDelete = false;
+
     if (!result) {
     if (!result) {
       this.sections = [];
       this.sections = [];
       return;
       return;
@@ -159,6 +162,10 @@ export class DashboardListCtrl {
     return this.getDashboards();
     return this.getDashboards();
   }
   }
 
 
+  onQueryChange() {
+    return this.getDashboards();
+  }
+
   onTagFilterChange() {
   onTagFilterChange() {
     this.query.tag.push(this.selectedTagFilter.term);
     this.query.tag.push(this.selectedTagFilter.term);
     this.selectedTagFilter = this.tagFilterOptions[0];
     this.selectedTagFilter = this.tagFilterOptions[0];

+ 1 - 1
public/app/features/dashboard/partials/dashboardList.html

@@ -17,7 +17,7 @@
       <div class="gf-form width-15">
       <div class="gf-form width-15">
         <span style="position: relative;">
         <span style="position: relative;">
           <input type="text" class="gf-form-input" placeholder="Find Dashboard by name" tabindex="1" give-focus="true"
           <input type="text" class="gf-form-input" placeholder="Find Dashboard by name" tabindex="1" give-focus="true"
-            ng-model="ctrl.query.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="ctrl.getDashboards()" />
+            ng-model="ctrl.query.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="ctrl.onQueryChange()" />
         </span>
         </span>
       </div>
       </div>
     </div>
     </div>

+ 10 - 0
public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts

@@ -110,6 +110,8 @@ describe('DashboardListCtrl', () => {
     describe('with no filter', () => {
     describe('with no filter', () => {
       beforeEach(() => {
       beforeEach(() => {
         ctrl.query.query = 'd';
         ctrl.query.query = 'd';
+        ctrl.canMove = true;
+        ctrl.canDelete = true;
         return ctrl.getDashboards();
         return ctrl.getDashboards();
       });
       });
 
 
@@ -120,6 +122,14 @@ describe('DashboardListCtrl', () => {
         expect(ctrl.sections[1].checked).toEqual(false);
         expect(ctrl.sections[1].checked).toEqual(false);
         expect(ctrl.sections[1].items[0].checked).toEqual(false);
         expect(ctrl.sections[1].items[0].checked).toEqual(false);
       });
       });
+
+      it('should disable Move To button', () => {
+        expect(ctrl.canMove).toBeFalsy();
+      });
+
+      it('should disable delete button', () => {
+        expect(ctrl.canDelete).toBeFalsy();
+      });
     });
     });
 
 
     describe('with tag filter', () => {
     describe('with tag filter', () => {

+ 4 - 0
public/sass/components/_search.scss

@@ -126,6 +126,10 @@
 
 
 .search-item__with-checkbox {
 .search-item__with-checkbox {
   display: flex;
   display: flex;
+
+  .search-item {
+    margin: 1px 3px;
+  }
 }
 }
 
 
 .search-item {
 .search-item {