소스 검색

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

Alex Antonenko 10 년 전
부모
커밋
2605a8450a

+ 1 - 1
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>

+ 5 - 1
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,

+ 74 - 11
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);
+      });
+    });
+
+  });
+
 });