ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-21831 Allow Hiding of PATCH Repository.(atkach)
Date Tue, 29 Aug 2017 09:35:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 2d56dcb6c -> 5388ae6d1


AMBARI-21831 Allow Hiding of PATCH Repository.(atkach)


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

Branch: refs/heads/trunk
Commit: 5388ae6d10eb84dd90174223668284690b665b0b
Parents: 2d56dcb
Author: Andrii Tkach <atkach@apache.org>
Authored: Tue Aug 29 12:30:51 2017 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Tue Aug 29 12:30:51 2017 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 31 +++++++
 .../app/mappers/repository_version_mapper.js    |  1 +
 .../models/stack_version/repository_version.js  |  1 +
 ambari-web/app/utils/ajax/ajax.js               | 15 ++++
 .../stack_upgrade/upgrade_version_box_view.js   | 17 +++-
 .../main/admin/stack_upgrade/versions_view.js   |  4 +-
 .../admin/stack_and_upgrade_controller_test.js  | 38 +++++++++
 .../upgrade_version_box_view_test.js            | 28 ++++++-
 .../admin/stack_upgrade/version_view_test.js    | 88 +++++++++++++-------
 9 files changed, 186 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index beaff0e..e0aeb09 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -2070,6 +2070,37 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   },
 
   /**
+   * @param {App.RepositoryVersion} version
+   * @returns {Em.Object}
+   */
+  confirmDiscardRepoVersion: function(version) {
+    var self = this;
+    return App.showConfirmationPopup(function() {
+      self.discardRepoVersion(version);
+    });
+  },
+
+  /**
+   * @param {App.RepositoryVersion} version
+   * @returns {$.ajax}
+   */
+  discardRepoVersion: function(version) {
+    this.set('requestInProgress', true);
+    return App.ajax.send({
+      name: 'admin.stack_versions.discard',
+      sender: this,
+      callback: function () {
+        this.sender.set('requestInProgress', false);
+      },
+      data: {
+        id: version.get('id'),
+        stackName: version.get('stackVersionType'),
+        stackVersion: version.get('stackVersionNumber')
+      },
+    });
+  },
+
+  /**
    * restore last Upgrade data
    * @param {object} lastUpgradeData
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/app/mappers/repository_version_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/repository_version_mapper.js b/ambari-web/app/mappers/repository_version_mapper.js
index 2527637..8b2014b 100644
--- a/ambari-web/app/mappers/repository_version_mapper.js
+++ b/ambari-web/app/mappers/repository_version_mapper.js
@@ -30,6 +30,7 @@ App.repoVersionMapper = App.QuickDataMapper.create({
       stack_version_id: repoVersionsKey + '.stackVersionId',
       display_name: repoVersionsKey + '.display_name',
       type: repoVersionsKey + '.type',
+      hidden: repoVersionsKey + '.hidden',
       repository_version: repoVersionsKey + '.repository_version',
       upgrade_pack: repoVersionsKey + '.upgrade_pack',
       stack_version_type: repoVersionsKey + '.stack_name',

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/app/models/stack_version/repository_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_version/repository_version.js b/ambari-web/app/models/stack_version/repository_version.js
index 6a0a5f0..3cb22b0 100644
--- a/ambari-web/app/models/stack_version/repository_version.js
+++ b/ambari-web/app/models/stack_version/repository_version.js
@@ -30,6 +30,7 @@ App.RepositoryVersion = DS.Model.extend({
   stackServices: DS.hasMany('App.ServiceSimple'),
   stackVersion: DS.belongsTo('App.StackVersion'),
   stack: Em.computed.concat(' ', 'stackVersionType', 'stackVersionNumber'),
+  hidden: DS.attr('boolean'),
   displayNameSimple: function() {
     return this.get('stackVersionType') + '-' + this.get('repositoryVersion').split('-')[0];
   }.property('stackVersionType', 'repositoryVersion'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index ab771e7..70a293c 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1852,6 +1852,21 @@ var urls = {
     }
   },
 
+  'admin.stack_versions.discard': {
+    'real': '/stacks/{stackName}/versions/{stackVersion}/repository_versions/{id}',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          "RepositoryVersions":{
+            "hidden": "true"
+          }
+        })
+      }
+    }
+  },
+
   'admin.upgrade.pre_upgrade_check': {
     'real': '/clusters/{clusterName}/rolling_upgrades_check?fields=*&UpgradeChecks/repository_version_id={id}&UpgradeChecks/upgrade_type={type}',
     'mock': '/data/stack_versions/pre_upgrade_check.json'

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/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 1831a30..ec3b4c9 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
@@ -182,8 +182,16 @@ App.UpgradeVersionBoxView = Em.View.extend({
       element.setProperties(statePropertiesMap[status]);
     }
     else if (status === 'NOT_REQUIRED') {
+      var isDisabledOnInit = this.isDisabledOnInit();
       requestInProgressRepoId && requestInProgressRepoId == this.get('content.id')
? element.setProperties(statePropertiesMap['LOADING']) : element.setProperties(statePropertiesMap[status]);
-      element.set('isDisabled', this.isDisabledOnInit());
+      element.set('isDisabled', isDisabledOnInit);
+      element.set('isButtonGroup', true);
+      element.set('isButton', false);
+      element.get('buttons').pushObject({
+        text: Em.I18n.t('common.discard'),
+        action: 'confirmDiscardRepoVersion',
+        isDisabled: isDisabledOnInit
+      });
     }
     else if ((status === 'INSTALLED' && !this.get('isUpgrading')) ||
              (['INSTALL_FAILED', 'OUT_OF_SYNC'].contains(status))) {
@@ -206,6 +214,13 @@ App.UpgradeVersionBoxView = Em.View.extend({
             action: 'installRepoVersionConfirmation',
             isDisabled: isDisabled
           });
+          if (this.get('content.isPatch')) {
+            element.get('buttons').pushObject({
+              text: Em.I18n.t('common.discard'),
+              action: 'confirmDiscardRepoVersion',
+              isDisabled: isDisabled
+            });
+          }
         }
         element.set('isDisabled', isDisabled);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
index f055feb..3166066 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
@@ -167,9 +167,9 @@ App.MainAdminStackVersionsView = Em.View.extend({
       }, this);
     }
     if (App.get('supports.displayOlderVersions') || Em.isNone(currentVersion)) {
-      return versions.toArray();
+      return versions.filterProperty('hidden', false).toArray();
     } else {
-      return versions.filter(function(v) {
+      return versions.filterProperty('hidden', false).filter(function(v) {
         if (v.get('stackVersionType') === Em.get(currentVersion, 'stack_name')) {
           // PATCH version should be visible even if patch number lower than current
           return v.get('isPatch') || stringUtils.compareVersions(v.get('repositoryVersion'),
Em.get(currentVersion, 'repository_version')) >= 0;

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index 71b9df1..0c70f16 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -3530,5 +3530,43 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       );
     });
   });
+  
+  describe('#confirmDiscardRepoVersion', function() {
+    beforeEach(function() {
+      sinon.stub(App, 'showConfirmationPopup', Em.clb);
+      sinon.stub(controller, 'discardRepoVersion');
+    });
+    afterEach(function() {
+      App.showConfirmationPopup.restore();
+      controller.discardRepoVersion.restore();
+    });
 
+    it('discardRepoVersion should be called', function() {
+      controller.confirmDiscardRepoVersion(Em.Object.create());
+      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+      expect(controller.discardRepoVersion.calledWith(Em.Object.create())).to.be.true;
+    });
+  });
+
+  describe('#discardRepoVersion', function() {
+
+    it('App.ajax.send should be called', function() {
+      var version = Em.Object.create({
+        id: 2,
+        stackVersionType: 'HDP',
+        stackVersionNumber: '2.5'
+      });
+      controller.discardRepoVersion(version);
+      expect(controller.get('requestInProgress')).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'admin.stack_versions.discard');
+      expect(args[0]).to.exists;
+      expect(args[0].data).to.be.eql({
+        id: 2,
+        stackName: 'HDP',
+        stackVersion: '2.5'
+      });
+      args[0].callback();
+      expect(controller.get('requestInProgress')).to.be.false;
+    });
+  });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/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 71519c5..d1c338f 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
@@ -478,8 +478,15 @@ describe('App.UpgradeVersionBoxView', function () {
         },
         expected: {
           status: 'NOT_REQUIRED',
-          isButton: true,
-          buttons: [],
+          isButton: false,
+          isButtonGroup: true,
+          buttons: [
+            {
+              "action": "confirmDiscardRepoVersion",
+              "isDisabled": false,
+              "text": "Discard"
+            }
+          ],
           isDisabled: true
         },
         title: 'NOT_REQUIRED state, no admin access, no requests in progress'
@@ -500,8 +507,15 @@ describe('App.UpgradeVersionBoxView', function () {
         },
         expected: {
           status: 'NOT_REQUIRED',
-          isButton: true,
-          buttons: [],
+          isButton: false,
+          isButtonGroup: true,
+          buttons: [
+            {
+              "action": "confirmDiscardRepoVersion",
+              "isDisabled": true,
+              "text": "Discard"
+            }
+          ],
           isDisabled: true
         },
         title: 'NOT_REQUIRED state, no admin access, request in progress, not installation'
@@ -671,6 +685,7 @@ describe('App.UpgradeVersionBoxView', function () {
         inputData: {
           'content.status': 'INSTALLED',
           'controller.requestInProgress': true,
+          'content.isPatch': true,
           'parentView.repoVersions': [
             Em.Object.create({
               status: 'INSTALLED'
@@ -698,6 +713,11 @@ describe('App.UpgradeVersionBoxView', function () {
               text: Em.I18n.t('admin.stackVersions.version.reinstall'),
               action: 'installRepoVersionConfirmation',
               isDisabled: true
+            },
+            {
+              "action": "confirmDiscardRepoVersion",
+              "isDisabled": true,
+              "text": "Discard"
             }
           ],
           isDisabled: true

http://git-wip-us.apache.org/repos/asf/ambari/blob/5388ae6d/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index a535d13..a58f38a 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -47,55 +47,65 @@ describe('App.mainAdminStackVersionsView', function () {
         Em.Object.create({
           status: "NOT_REQUIRED",
           repositoryVersion: "2.2.1.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "INSTALLING",
           repositoryVersion: "2.2.1.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "INSTALLED",
           repositoryVersion: "2.0.2.1",
           stackVersionType: 'HCP',
-          isCompatible: true
+          isCompatible: true,
+          hidden: false
         }),
         Em.Object.create({
           status: "INSTALLED",
           repositoryVersion: "2.0.2.2",
           stackVersionType: 'HCP',
-          isCompatible: false
+          isCompatible: false,
+          hidden: false
         }),
         Em.Object.create({
           status: "INSTALLED",
           repositoryVersion: "2.2.2.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "INSTALLED",
           repositoryVersion: "2.2.3.1",
           displayName: 'HDP-2.2',
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "INSTALL_FAILED",
           repositoryVersion: "2.2.1.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "OUT_OF_SYNC",
           repositoryVersion: "2.2.1.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "UPGRADED",
           repositoryVersion: "2.2.1.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         }),
         Em.Object.create({
           status: "CURRENT",
           repositoryVersion: "2.2.1.1",
-          stackVersionType: 'HDP'
+          stackVersionType: 'HDP',
+          hidden: false
         })
       ],
       testCases = [
@@ -107,49 +117,58 @@ describe('App.mainAdminStackVersionsView', function () {
             Em.Object.create({
               status: "NOT_REQUIRED",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALLING",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALLED",
               repositoryVersion: "2.0.2.1",
               stackVersionType: 'HCP',
-              isCompatible: true
+              isCompatible: true,
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALLED",
               repositoryVersion: "2.2.2.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALLED",
               repositoryVersion: "2.2.3.1",
               displayName: 'HDP-2.2',
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALL_FAILED",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "OUT_OF_SYNC",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "UPGRADED",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "CURRENT",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             })
           ]
         },
@@ -161,22 +180,26 @@ describe('App.mainAdminStackVersionsView', function () {
             Em.Object.create({
               status: "NOT_REQUIRED",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALLING",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "INSTALL_FAILED",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             }),
             Em.Object.create({
               status: "OUT_OF_SYNC",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             })
           ]
         },
@@ -189,7 +212,8 @@ describe('App.mainAdminStackVersionsView', function () {
               status: "INSTALLED",
               repositoryVersion: "2.0.2.1",
               stackVersionType: 'HCP',
-              isCompatible: true
+              isCompatible: true,
+              hidden: false
             })
           ]
         },
@@ -201,7 +225,8 @@ describe('App.mainAdminStackVersionsView', function () {
             Em.Object.create({
               status: "INSTALLED",
               repositoryVersion: "2.2.2.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             })
           ]
         },
@@ -213,7 +238,8 @@ describe('App.mainAdminStackVersionsView', function () {
             Em.Object.create({
               status: "CURRENT",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             })
           ]
         },
@@ -226,7 +252,8 @@ describe('App.mainAdminStackVersionsView', function () {
               status: "INSTALLED",
               repositoryVersion: "2.2.3.1",
               displayName: 'HDP-2.2',
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             })
           ]
         },
@@ -238,7 +265,8 @@ describe('App.mainAdminStackVersionsView', function () {
             Em.Object.create({
               status: "UPGRADED",
               repositoryVersion: "2.2.1.1",
-              stackVersionType: 'HDP'
+              stackVersionType: 'HDP',
+              hidden: false
             })
           ]
         },
@@ -247,7 +275,7 @@ describe('App.mainAdminStackVersionsView', function () {
           filter:  Em.Object.create({
             value: ''
           }),
-          filteredVersions: versions,
+          filteredVersions: versions.filterProperty('hidden', false),
           message: 'no current version'
         },
         {
@@ -255,7 +283,7 @@ describe('App.mainAdminStackVersionsView', function () {
           filter:  Em.Object.create({
             value: ''
           }),
-          filteredVersions: versions,
+          filteredVersions: versions.filterProperty('hidden', false),
           message: 'display older versions'
         }
       ];


Mime
View raw message