ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-12254. Disable/hide 'Add Service' link on 'Stack' page during RU (onechiporenko)
Date Thu, 02 Jul 2015 12:47:48 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 da3582912 -> 0dd18ed64


AMBARI-12254. Disable/hide 'Add Service' link on 'Stack' page during RU (onechiporenko)


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

Branch: refs/heads/branch-2.1
Commit: 0dd18ed64ac68d06e7d34d2a03b24388ee11730a
Parents: da35829
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Thu Jul 2 15:40:49 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Thu Jul 2 15:45:53 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/styles/application.less          |  5 +++
 .../main/admin/stack_upgrade/services.hbs       |  2 +-
 .../main/admin/stack_upgrade/services_view.js   |  8 +++-
 .../admin/stack_upgrade/services_view_test.js   | 41 ++++++++++++++++++--
 4 files changed, 51 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0dd18ed6/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 42ca66e..6313a01 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -5717,6 +5717,11 @@ input[type="radio"].align-checkbox, input[type="checkbox"].align-checkbox
{
 .path-link {
   white-space: nowrap;
   cursor: pointer;
+  &.not-active-link:hover {
+    color: #999;
+    text-decoration: none;
+    cursor: default;
+  }
 }
 
 .bottom-border {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dd18ed6/ambari-web/app/templates/main/admin/stack_upgrade/services.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/services.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/services.hbs
index 56d13bf..a87c50c 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/services.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/services.hbs
@@ -35,7 +35,7 @@
         {{#if service.isInstalled}}
           <span class="label label-success">{{t common.installed}}</span>
         {{else}}
-          <a class="path-link" {{action goToAddService service.serviceName target="view"}}>
+          <a {{bindAttr class=":path-link view.isAddServiceAvailable::not-active-link"}}
{{action goToAddService service.serviceName target="view"}}>
             {{t services.service.add}}</a>
         {{/if}}
       </td>

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dd18ed6/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/services_view.js b/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
index db38a4c..edc4a36 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
@@ -22,6 +22,10 @@ var App = require('app');
 App.MainAdminStackServicesView = Em.View.extend({
   templateName: require('templates/main/admin/stack_upgrade/services'),
 
+  isAddServiceAvailable: function () {
+    return App.isAccessible('ADMIN');
+  }.property('App.supports.opsDuringRollingUpgrade', 'App.upgradeState', 'App.isAdmin'),
+
   /**
    * @type {Array}
    */
@@ -44,7 +48,9 @@ App.MainAdminStackServicesView = Em.View.extend({
    * @param event
    */
   goToAddService: function (event) {
-    if (event.context == "KERBEROS") {
+    if (!App.isAccessible('ADMIN')) {
+      return;
+    } else if (event.context == "KERBEROS") {
       App.router.get('mainAdminKerberosController').checkAndStartKerberosWizard();
       App.router.get('kerberosWizardController').setDBProperty('onClosePath', 'main.admin.stackAndUpgrade.services');
     } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dd18ed6/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
index 8e1f116..3154449 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
@@ -48,29 +48,64 @@ describe('App.MainAdminStackServicesView', function () {
 
   describe("#goToAddService()" , function() {
     var mock = Em.Object.create({
-      checkAndStartKerberosWizard: Em.K,
-      setDBProperty: sinon.spy()
-    });
+        checkAndStartKerberosWizard: Em.K,
+        setDBProperty: sinon.spy()
+      }),
+      isAccessibleMock;
     beforeEach(function() {
       sinon.stub(App.get('router'), 'transitionTo', Em.K);
       sinon.stub(App.router, 'get').returns(mock);
       sinon.spy(mock, 'checkAndStartKerberosWizard');
+      isAccessibleMock = sinon.stub(App, 'isAccessible');
     });
     afterEach(function() {
       App.get('router').transitionTo.restore();
       App.router.get.restore();
       mock.checkAndStartKerberosWizard.restore();
+      App.isAccessible.restore();
+    });
+    it ("operations locked", function () {
+      isAccessibleMock.returns(false);
+      view.goToAddService();
+      expect(App.router.get.called).to.be.false;
+      expect(App.get('router').transitionTo.called).to.be.false;
     });
     it("routes to Add Service Wizard and set redirect path on wizard close", function() {
+      isAccessibleMock.returns(true);
       view.goToAddService({context: "serviceName"});
       expect(App.router.get.calledWith('addServiceController') && mock.setDBProperty.calledWith('onClosePath',
'main.admin.stackAndUpgrade.services')).to.be.true;
       expect(App.get('router').transitionTo.calledWith('main.serviceAdd')).to.be.true;
       expect(mock.get('serviceToInstall')).to.be.equal("serviceName");
     });
     it("routes to Security Wizard", function() {
+      isAccessibleMock.returns(true);
       view.goToAddService({context: "KERBEROS"});
       expect(App.router.get.calledWith('kerberosWizardController') && mock.setDBProperty.calledWith('onClosePath',
'main.admin.stackAndUpgrade.services')).to.be.true;
       expect(mock.checkAndStartKerberosWizard.calledOnce).to.be.true;
     });
   });
+
+  describe('#isAddServiceAvailable', function () {
+
+    var cases = [true, false],
+      titleTemplate = 'should be {0}',
+      isAccessibleMock;
+
+    beforeEach(function() {
+      isAccessibleMock = sinon.stub(App, 'isAccessible');
+    });
+
+    afterEach(function() {
+      App.isAccessible.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(titleTemplate.format(item.toString()), function () {
+        isAccessibleMock.returns(item);
+        view.propertyDidChange('isAddServiceAvailable');
+        expect(view.get('isAddServiceAvailable')).to.equal(item);
+      });
+    });
+
+  });
 });


Mime
View raw message