ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-14404. Ambari Admin: incorrect cluster filter behaviour on Versions page
Date Fri, 18 Dec 2015 16:55:00 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d090dbf78 -> 2c7ecd12e


AMBARI-14404. Ambari Admin: incorrect cluster filter behaviour on Versions page


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2c7ecd12
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2c7ecd12
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2c7ecd12

Branch: refs/heads/trunk
Commit: 2c7ecd12ece30851395d518e6ad3f1fdf8b94cf9
Parents: d090dbf
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Thu Dec 17 20:49:38 2015 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Dec 18 18:50:42 2015 +0200

----------------------------------------------------------------------
 .../stackVersions/StackVersionsListCtrl.js      | 13 +++--
 .../admin-web/app/views/stackVersions/list.html |  2 +-
 .../stackVersions/StackversionsListCtrl_test.js | 53 ++++++++++++++++++--
 3 files changed, 57 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2c7ecd12/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js
index a9d3edb..3137d5c 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js
@@ -89,10 +89,8 @@ angular.module('ambariAdminConsole')
     });
   };
 
-  $scope.fillClusters = function (clusters) {
-    $scope.dropDownClusters = [].concat(clusters);
-    $scope.selectedCluster = $scope.dropDownClusters[0];
-    angular.forEach(clusters, function (cluster) {
+    $scope.fillClusters = function (clusters) {
+      $scope.dropDownClusters = [].concat(clusters);
       var options = [{label: "All", value: ''}];
       angular.forEach(clusters, function (cluster) {
         options.push({
@@ -101,9 +99,10 @@ angular.module('ambariAdminConsole')
         });
       });
       $scope.filter.cluster.options = options;
-      $scope.filter.cluster.current = options[0];
-    });
-  };
+      if (!$scope.filter.cluster.current) {
+        $scope.filter.cluster.current = options[0];
+      }
+    };
 
   $scope.fetchClusters = function () {
     return Cluster.getAllClusters().then(function (clusters) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c7ecd12/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html
index e4db634..1fa5aed 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/list.html
@@ -41,7 +41,7 @@
         <select class="form-control"
                 ng-change="resetPagination()"
                 ng-model="filter.cluster.current"
-                ng-options="item.label for item in filter.cluster.options"
+                ng-options="item.label for item in filter.cluster.options track by item.value"
           ></select>
       </th>
       <th></th>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c7ecd12/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackversionsListCtrl_test.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackversionsListCtrl_test.js
b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackversionsListCtrl_test.js
index d3c1b2e..f7a778a 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackversionsListCtrl_test.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackversionsListCtrl_test.js
@@ -29,10 +29,57 @@ describe('#Cluster', function () {
       ctrl = $controller('StackVersionsListCtrl', {$scope: scope});
     }));
 
-    it('saves list of stacks', function() {
-      scope.fetchRepos().then(function() {
-        expect(Array.isArray(scope.repos)).toBe(true);
+    describe('fetchRepos()', function () {
+
+      it('saves list of stacks', function() {
+        scope.fetchRepos().then(function() {
+          expect(Array.isArray(scope.repos)).toBe(true);
+        });
       });
+
     });
+
+    describe('fillClusters()', function () {
+
+      var clusters = [
+          {
+            Clusters: {
+              cluster_name: 'c0'
+            }
+          }
+        ],
+        cases = [
+          {
+            prev: null,
+            current: {
+              label: 'All',
+              value: ''
+            },
+            title: 'no cluster selected before'
+          },
+          {
+            prev: {
+              label: 'c0',
+              value: 'c0'
+            },
+            current: {
+              label: 'c0',
+              value: 'c0'
+            },
+            title: 'cluster was selected before'
+          }
+        ];
+
+      angular.forEach(cases, function (item) {
+        it(item.title, function() {
+          scope.filter.cluster.current = item.prev;
+          scope.fillClusters(clusters);
+          expect(scope.dropDownClusters).toEqual(clusters);
+          expect(scope.filter.cluster.current).toEqual(item.current);
+        });
+      });
+
+    });
+
   });
 });


Mime
View raw message