瀏覽代碼

AMBARI-14530. Ambari Admin: Admin filter remains active after clearing all filters in Users table (alexantonenko)

Alex Antonenko 9 年之前
父節點
當前提交
371376de42

+ 2 - 1
ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/users/UsersListCtrl.js

@@ -92,6 +92,7 @@ angular.module('ambariAdminConsole')
     $scope.currentNameFilter = '';
     $scope.currentTypeFilter = $scope.typeFilterOptions[0];
     $scope.currentActiveFilter = $scope.activeFilterOptions[0];
+    $scope.adminFilter = false;
     $scope.resetPagination();
   };
 
@@ -100,7 +101,7 @@ angular.module('ambariAdminConsole')
   $scope.$watch(
     function (scope) {
       return Boolean(scope.currentNameFilter || (scope.currentActiveFilter && scope.currentActiveFilter.value !== '*')
-        || (scope.currentTypeFilter && scope.currentTypeFilter.value !== '*'));
+        || (scope.currentTypeFilter && scope.currentTypeFilter.value !== '*') || $scope.adminFilter);
     },
     function (newValue, oldValue, scope) {
       scope.isNotEmptyFilter = newValue;

+ 160 - 0
ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/users/UsersListCtrl_test.js

@@ -46,6 +46,7 @@ describe('#Cluster', function () {
           label: $t('common.local'),
           value: 'LOCAL'
         };
+        scope.adminFilter = true;
         scope.clearFilters();
         expect(scope.currentNameFilter).toEqual('');
         expect(scope.currentActiveFilter).toEqual({
@@ -57,6 +58,7 @@ describe('#Cluster', function () {
           value: '*'
         });
         expect(scope.currentPage).toEqual(1);
+        expect(scope.adminFilter).toBe(false);
       });
 
     });
@@ -69,6 +71,7 @@ describe('#Cluster', function () {
           currentTypeFilter: null,
           currentActiveFilter: null,
           isNotEmptyFilter: false,
+          adminFilter: false,
           title: 'no filters'
         },
         {
@@ -79,6 +82,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: '*'
           },
+          adminFilter: false,
           isNotEmptyFilter: false,
           title: 'empty filters'
         },
@@ -90,6 +94,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: '*'
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'name filter'
         },
@@ -101,6 +106,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: '*'
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'name filter with "0" as string'
         },
@@ -112,6 +118,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: '*'
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'type filter'
         },
@@ -123,9 +130,22 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: false
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'activity filter'
         },
+        {
+          currentNameFilter: '',
+          currentTypeFilter: {
+            value: '*'
+          },
+          currentActiveFilter: {
+            value: '*'
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'admin filter'
+        },
         {
           currentNameFilter: 'a',
           currentTypeFilter: {
@@ -134,6 +154,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: '*'
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'name and type filters'
         },
@@ -145,9 +166,22 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: false
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'name and activity filters'
         },
+        {
+          currentNameFilter: 'a',
+          currentTypeFilter: {
+            value: '*'
+          },
+          currentActiveFilter: {
+            value: '*'
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'name and admin filters'
+        },
         {
           currentNameFilter: '0',
           currentTypeFilter: {
@@ -156,6 +190,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: '*'
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'name and type filters with "0" as string'
         },
@@ -167,9 +202,22 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: false
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'name and activity filters with "0" as string'
         },
+        {
+          currentNameFilter: '0',
+          currentTypeFilter: {
+            value: '*'
+          },
+          currentActiveFilter: {
+            value: '*'
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'name and admin filters with "0" as string'
+        },
         {
           currentNameFilter: '',
           currentTypeFilter: {
@@ -178,9 +226,118 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: false
           },
+          adminFilter: false,
           isNotEmptyFilter: true,
           title: 'type and activity filters'
         },
+        {
+          currentNameFilter: '',
+          currentTypeFilter: {
+            value: 'LOCAL'
+          },
+          currentActiveFilter: {
+            value: '*'
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'type and admin filters'
+        },
+        {
+          currentNameFilter: '',
+          currentTypeFilter: {
+            value: '*'
+          },
+          currentActiveFilter: {
+            value: false
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'activity and admin filters'
+        },
+        {
+          currentNameFilter: '',
+          currentTypeFilter: {
+            value: 'LOCAL'
+          },
+          currentActiveFilter: {
+            value: false
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'all filters except name one'
+        },
+        {
+          currentNameFilter: 'a',
+          currentTypeFilter: {
+            value: '*'
+          },
+          currentActiveFilter: {
+            value: false
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'all filters except type one'
+        },
+        {
+          currentNameFilter: 'a',
+          currentTypeFilter: {
+            value: 'LOCAL'
+          },
+          currentActiveFilter: {
+            value: '*'
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'all filters except activity one'
+        },
+        {
+          currentNameFilter: 'a',
+          currentTypeFilter: {
+            value: 'LOCAL'
+          },
+          currentActiveFilter: {
+            value: false
+          },
+          adminFilter: false,
+          isNotEmptyFilter: true,
+          title: 'all filters except admin one'
+        },
+        {
+          currentNameFilter: '0',
+          currentTypeFilter: {
+            value: '*'
+          },
+          currentActiveFilter: {
+            value: false
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'all filters with "0" as string except type one'
+        },
+        {
+          currentNameFilter: '0',
+          currentTypeFilter: {
+            value: 'LOCAL'
+          },
+          currentActiveFilter: {
+            value: '*'
+          },
+          adminFilter: true,
+          isNotEmptyFilter: true,
+          title: 'all filters with "0" as string except activity one'
+        },
+        {
+          currentNameFilter: '0',
+          currentTypeFilter: {
+            value: 'LOCAL'
+          },
+          currentActiveFilter: {
+            value: false
+          },
+          adminFilter: false,
+          isNotEmptyFilter: true,
+          title: 'all filters with "0" as string except admin one'
+        },
         {
           currentNameFilter: 'a',
           currentTypeFilter: {
@@ -189,6 +346,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: 'LOCAL'
           },
+          adminFilter: true,
           isNotEmptyFilter: true,
           title: 'all filters'
         },
@@ -200,6 +358,7 @@ describe('#Cluster', function () {
           currentActiveFilter: {
             value: 'LOCAL'
           },
+          adminFilter: true,
           isNotEmptyFilter: true,
           title: 'all filters with "0" as string'
         }
@@ -211,6 +370,7 @@ describe('#Cluster', function () {
           scope.currentNameFilter = item.currentNameFilter;
           scope.currentActiveFilter = item.currentActiveFilter;
           scope.currentTypeFilter = item.currentTypeFilter;
+          scope.adminFilter = item.adminFilter;
           scope.$digest();
           expect(scope.isNotEmptyFilter).toEqual(item.isNotEmptyFilter);
         });