ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject ambari git commit: AMBARI-10328. No 'Manage Ambari' link on step 9 of Install Wizard after relogin. (akovalenko)
Date Fri, 03 Apr 2015 11:58:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f34f2df9c -> 888a24daa


AMBARI-10328. No 'Manage Ambari' link on step 9 of Install Wizard after relogin. (akovalenko)


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

Branch: refs/heads/trunk
Commit: 888a24daa3260d011508bd11e2e36529b4e90a59
Parents: f34f2df
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Fri Apr 3 13:53:47 2015 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Fri Apr 3 13:53:47 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/app.js                    |  1 +
 ambari-web/app/router.js                 | 15 +++++--
 ambari-web/app/templates/application.hbs | 12 +++---
 ambari-web/test/router_test.js           | 61 +++++++++++++++++++++++++++
 4 files changed, 80 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/888a24da/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 38ba4bd..60bc27c 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -34,6 +34,7 @@ module.exports = Em.Application.create({
   }),
   isAdmin: false,
   isOperator: false,
+  isPermissionDataLoaded: false,
 
   /**
    * state of stack upgrade process

http://git-wip-us.apache.org/repos/asf/ambari/blob/888a24da/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index fe37e0e..a256fee 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -299,14 +299,17 @@ App.Router = Em.Router.extend({
           var clusterName = clustersData.items[0].Clusters.cluster_name;
           var clusterPermissions = privileges.filterProperty('PrivilegeInfo.cluster_name',
clusterName).mapProperty('PrivilegeInfo.permission_name');
           if (clusterPermissions.contains('CLUSTER.OPERATE')) {
-            App.set('isAdmin', true);
-            App.set('isOperator', true);
+            App.setProperties({
+              isAdmin: true,
+              isOperator: true
+            });
             transitionToApp = true;
           } else if (clusterPermissions.contains('CLUSTER.READ')) {
             transitionToApp = true;
           }
         }
       }
+      App.set('isPermissionDataLoaded', true);
       if (transitionToApp) {
         if (!Em.isNone(router.get('preferedPath'))) {
           window.location = router.get('preferedPath');
@@ -384,8 +387,11 @@ App.Router = Em.Router.extend({
     // otherwise, this.set('installerController.currentStep, 0) would have no effect
     // since it's a computed property but we are not setting it as a dependent of App.db.
     App.db.cleanUp();
-    App.set('isAdmin', false);
-    App.set('isOperator', false);
+    App.setProperties({
+      isAdmin: false,
+      isOperator: false,
+      isPermissionDataLoaded: false
+    });
     this.set('loggedIn', false);
     this.clearAllSteps();
     console.log("Log off: " + App.router.getClusterName());
@@ -435,6 +441,7 @@ App.Router = Em.Router.extend({
         if (user.operator) {
           App.set('isOperator', true);
         }
+        App.set('isPermissionDataLoaded', true);
       }
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/888a24da/ambari-web/app/templates/application.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/application.hbs b/ambari-web/app/templates/application.hbs
index 63da6e7..10897e9 100644
--- a/ambari-web/app/templates/application.hbs
+++ b/ambari-web/app/templates/application.hbs
@@ -68,11 +68,13 @@
                     {{/isAccessible}}
                   {{/if}}
                 {{else}}
-                  {{#isAccessible upgrade_ONLY_ADMIN}}
-                    <li><a href=""
-                           id="manage-ambari" {{action goToAdminView target="controller"}}>{{t
app.manageAmbari}}</a>
-                    </li>
-                  {{/isAccessible}}
+                  {{#if App.isPermissionDataLoaded}}
+                    {{#isAccessible upgrade_ONLY_ADMIN}}
+                      <li><a href=""
+                             id="manage-ambari" {{action goToAdminView target="controller"}}>{{t
app.manageAmbari}}</a>
+                      </li>
+                    {{/isAccessible}}
+                  {{/if}}
                 {{/if}}
                 {{#if isClusterDataLoaded}}
                   {{#isAccessible upgrade_ADMIN}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/888a24da/ambari-web/test/router_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/router_test.js b/ambari-web/test/router_test.js
index ec76aff..eefb35a 100644
--- a/ambari-web/test/router_test.js
+++ b/ambari-web/test/router_test.js
@@ -47,4 +47,65 @@ describe('App.Router', function () {
     })
   });
 
+  describe('#initAdmin()', function () {
+
+    var cases = [
+      {
+        user: {
+          admin: true
+        },
+        isAdmin: true,
+        isOperator: false,
+        isPermissionDataLoaded: true,
+        title: 'admin'
+      },
+      {
+        user: {
+          operator: true
+        },
+        isAdmin: false,
+        isOperator: true,
+        isPermissionDataLoaded: true,
+        title: 'operator'
+      },
+      {
+        user: {},
+        isAdmin: false,
+        isOperator: false,
+        isPermissionDataLoaded: true,
+        title: 'read only access'
+      },
+      {
+        user: null,
+        isAdmin: false,
+        isOperator: false,
+        isPermissionDataLoaded: false,
+        title: 'no user'
+      }
+    ];
+
+    beforeEach(function () {
+      App.setProperties({
+        isAdmin: false,
+        isOperator: false,
+        isPermissionDataLoaded: false
+      });
+    });
+
+    afterEach(function () {
+      App.db.getUser.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        sinon.stub(App.db, 'getUser').returns(item.user);
+        router.initAdmin();
+        expect(App.get('isAdmin')).to.equal(item.isAdmin);
+        expect(App.get('isOperator')).to.equal(item.isOperator);
+        expect(App.get('isPermissionDataLoaded')).to.equal(item.isPermissionDataLoaded);
+      });
+    });
+
+  });
+
 });


Mime
View raw message