ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/3] ambari git commit: AMBARI-12494. Editing repo versions URLs is enabled regardless of version status (alexantonenko)
Date Wed, 22 Jul 2015 14:02:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 b9f4499ed -> f90f1e644


AMBARI-12494. Editing repo versions URLs is enabled regardless of version status (alexantonenko)


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

Branch: refs/heads/branch-2.1
Commit: 7a61027b41ddcafa74fcc9cbd4fdaf11b9c8cc8a
Parents: b9f4499
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Wed Jul 22 14:30:36 2015 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Wed Jul 22 17:01:57 2015 +0300

----------------------------------------------------------------------
 .../admin/stack_upgrade/upgrade_version_box.hbs |  2 +-
 .../stack_upgrade/upgrade_version_box_view.js   |  6 +-
 .../upgrade_version_box_view_test.js            | 85 +++++++++++++++++---
 3 files changed, 80 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7a61027b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs
index 2e037d1..be5df49 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs
@@ -20,7 +20,7 @@
   <i class="icon-exclamation-sign out-of-sync-badge"></i>
 {{/if}}
 
-<p class="version">
+<p {{bindAttr class=":version view.isRepoUrlsEditDisabled:not-active-link"}}>
   <span>{{view.content.displayName}}</span>
   <a class="pull-right not-active link-tooltip" {{action editRepositories target="view"}}>
     <i class="icon-edit"></i>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7a61027b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index 9e6d5ad..377db71 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -49,6 +49,10 @@ App.UpgradeVersionBoxView = Em.View.extend({
     return (this.get('controller.upgradeVersion') === this.get('content.displayName') &&
App.get('upgradeState') !== 'INIT');
   }.property('App.upgradeState', 'content.displayName', 'controller.upgradeVersion'),
 
+  isRepoUrlsEditDisabled: function () {
+    return ['INSTALLING', 'UPGRADING'].contains(this.get('content.status')) || this.get('isUpgrading');
+  }.property('content.status', 'isUpgrading'),
+
   /**
    * @type {string}
    */
@@ -239,7 +243,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
       })
     });
 
-    return App.ModalPopup.show({
+    return this.get('isRepoUrlsEditDisabled') ? null : App.ModalPopup.show({
       classNames: ['repository-list', 'sixty-percent-width-modal'],
       skipValidation: false,
       autoHeight: false,

http://git-wip-us.apache.org/repos/asf/ambari/blob/7a61027b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index 080bf39..7654411 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -21,14 +21,19 @@ var App = require('app');
 require('views/main/admin/stack_upgrade/upgrade_version_box_view');
 
 describe('App.UpgradeVersionBoxView', function () {
-  var view = App.UpgradeVersionBoxView.create({
-    controller: Em.Object.create({
-      upgrade: Em.K
-    }),
-    content: Em.Object.create(),
-    parentView: Em.Object.create({
-      repoVersions: []
-    })
+
+  var view;
+
+  beforeEach(function () {
+    view = App.UpgradeVersionBoxView.create({
+      controller: Em.Object.create({
+        upgrade: Em.K
+      }),
+      content: Em.Object.create(),
+      parentView: Em.Object.create({
+        repoVersions: []
+      })
+    });
   });
 
   describe("#isUpgrading", function () {
@@ -212,6 +217,18 @@ describe('App.UpgradeVersionBoxView', function () {
   });
   
   describe("#editRepositories()", function () {
+    var cases = [
+      {
+        isRepoUrlsEditDisabled: true,
+        popupShowCallCount: 0,
+        title: 'edit repo URLS disabled, popup shouldn\'t be shown'
+      },
+      {
+        isRepoUrlsEditDisabled: false,
+        popupShowCallCount: 1,
+        title: 'edit repo URLS enabled, popup should be shown'
+      }
+    ];
     beforeEach(function () {
       sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({
         operatingSystems: []
@@ -222,9 +239,14 @@ describe('App.UpgradeVersionBoxView', function () {
       App.RepositoryVersion.find.restore();
       App.ModalPopup.show.restore();
     });
-    it("show popup", function () {
-      view.editRepositories();
-      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        view.reopen({
+          isRepoUrlsEditDisabled: item.isRepoUrlsEditDisabled
+        });
+        view.editRepositories();
+        expect(App.ModalPopup.show.callCount).to.equal(item.popupShowCallCount);
+      });
     });
   });
 
@@ -767,4 +789,45 @@ describe('App.UpgradeVersionBoxView', function () {
 
   });
 
+  describe('#isRepoUrlsEditDisabled', function () {
+
+    var cases = [
+      {
+        status: 'INSTALLING',
+        isUpgrading: false,
+        isRepoUrlsEditDisabled: true,
+        title: 'installing packages'
+      },
+      {
+        status: 'UPGRADING',
+        isUpgrading: true,
+        isRepoUrlsEditDisabled: true,
+        title: 'upgrading'
+      },
+      {
+        status: 'INSTALLED',
+        isUpgrading: true,
+        isRepoUrlsEditDisabled: true,
+        title: 'upgrading just started'
+      },
+      {
+        status: 'INIT',
+        isUpgrading: false,
+        isRepoUrlsEditDisabled: false,
+        title: 'neither upgrading nor installing packages'
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        view.reopen({
+          isUpgrading: item.isUpgrading
+        });
+        view.set('content.status', item.status);
+        expect(view.get('isRepoUrlsEditDisabled')).to.equal(item.isRepoUrlsEditDisabled);
+      });
+    });
+
+  });
+
 });


Mime
View raw message