Explorar el Código

AMBARI-15243. Message for Ambari admin user isn't displayed in User Settings popup (alexantonenko)

Alex Antonenko hace 9 años
padre
commit
4c5e03b849

+ 1 - 0
ambari-web/app/messages.js

@@ -53,6 +53,7 @@ Em.I18n.translations = {
   'app.settings.no.cluster.privileges': 'No cluster privileges',
   'app.settings.admin.all.privileges': 'This user is an Ambari Admin and has all privileges.',
   'app.settings.no.privileges': 'This user does not have any privileges.',
+  'app.settings.clusterRole': 'Cluster Role',
   'app.settings.viewPermissions': 'View Permissions',
 
   'app.aboutAmbari.getInvolved': 'Get involved!',

+ 1 - 1
ambari-web/app/router.js

@@ -406,7 +406,7 @@ App.Router = Em.Router.extend({
       self = this,
       requestData = {
         loginName: params.loginName,
-        loginData: data
+        loginData: params.loginData
       };
     // no need to load cluster data if it's already loaded
     if (this.get('clusterData')) {

+ 2 - 2
ambari-web/app/templates/common/settings.hbs

@@ -44,8 +44,8 @@
       <table class="table">
         <thead>
         <tr>
-          <th>Cluster</th>
-          <th>Cluster Role</th>
+          <th>{{t common.cluster}}</th>
+          <th>{{t app.settings.clusterRole}}</th>
         </tr>
         </thead>
         <tbody>

+ 79 - 0
ambari-web/test/router_test.js

@@ -497,4 +497,83 @@ describe('App.Router', function () {
 
   });
 
+  describe('#setClusterData', function () {
+
+    var data = {
+        loginName: 'user',
+        loginData: {
+          PrivilegeInfo: {}
+        }
+      },
+      clusterData = {
+        items: []
+      },
+      cases = [
+        {
+          clusterData: clusterData,
+          callbackCallCount: 1,
+          isAjaxCalled: false,
+          title: 'cluster data available'
+        },
+        {
+          clusterData: null,
+          callbackCallCount: 0,
+          isAjaxCalled: true,
+          title: 'no cluster data'
+        }
+      ];
+
+    beforeEach(function () {
+      sinon.stub(router, 'loginGetClustersSuccessCallback', Em.K);
+    });
+
+    afterEach(function () {
+      router.loginGetClustersSuccessCallback.restore();
+    });
+
+    cases.forEach(function (item) {
+
+      describe(item.title, function () {
+
+        var ajaxCallArgs;
+
+        beforeEach(function () {
+          router.set('clusterData', item.clusterData);
+          router.setClusterData({}, {}, data);
+          ajaxCallArgs = testHelpers.findAjaxRequest('name', 'router.login.clusters');
+        });
+
+        it('loginGetClustersSuccessCallback', function () {
+          expect(router.loginGetClustersSuccessCallback.callCount).to.equal(item.callbackCallCount);
+        });
+
+        if (item.isAjaxCalled) {
+          it('App.ajax.send is called', function () {
+            expect(ajaxCallArgs).to.have.length(1);
+          });
+          it('data for AJAX request', function () {
+            expect(ajaxCallArgs).to.eql([
+              {
+                name: 'router.login.clusters',
+                sender: router,
+                data: data,
+                success: 'loginGetClustersSuccessCallback'
+              }
+            ]);
+          });
+        } else {
+          it('App.ajax.send is not called', function () {
+            expect(ajaxCallArgs).to.be.undefined;
+          });
+          it('arguments for callback', function () {
+            expect(router.loginGetClustersSuccessCallback.firstCall.args).to.eql([clusterData, {}, data]);
+          });
+        }
+
+      });
+
+    });
+
+  });
+
 });