ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sangee...@apache.org
Subject ambari git commit: AMBARI-21052: Regex pattern for version number in Register Version UI should depend on stack's version dir (sangeetar)
Date Tue, 23 May 2017 21:02:56 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk cd769e2e7 -> b5fdb57c5


AMBARI-21052: Regex pattern for version number in Register Version UI should depend on stack's
version dir (sangeetar)


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

Branch: refs/heads/trunk
Commit: b5fdb57c5173cbf241782e9daa6dee4f4dc63c3c
Parents: cd769e2
Author: Sangeeta Ravindran <sangeetar@apache.org>
Authored: Tue May 23 14:02:10 2017 -0700
Committer: Sangeeta Ravindran <sangeetar@apache.org>
Committed: Tue May 23 14:02:10 2017 -0700

----------------------------------------------------------------------
 .../stackVersions/StackVersionsCreateCtrl.js    |  1 -
 .../ui/admin-web/app/scripts/i18n.config.js     |  2 +-
 .../ui/admin-web/app/scripts/services/Stack.js  | 32 +++++++++++++++++++-
 .../views/stackVersions/stackVersionPage.html   |  4 +--
 .../StackVersionsCreateCtrl_test.js             |  6 ++--
 5 files changed, 37 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b5fdb57c/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
index 69c35c0..70f6658 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
@@ -34,7 +34,6 @@ angular.module('ambariAdminConsole')
   $scope.useRedhatSatellite = false;
 
   $scope.clusterName = $routeParams.clusterName;
-  $scope.subversionPattern = /^\d+\.\d+(-\d+)?$/;
   $scope.upgradeStack = {
     stack_name: '',
     stack_version: '',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5fdb57c/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
index fd2c6e5..43b32da 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
@@ -374,7 +374,7 @@ angular.module('ambariAdminConsole')
 
     'versions.deregister': 'Deregister Version',
     'versions.deregisterConfirmation': 'Are you sure you want to deregister version <strong>{{versionName}}</strong>
?',
-    'versions.placeholder': 'Version Number (0.0)',
+    'versions.placeholder': 'Version Number {{pattern}}',
     'versions.repos': 'Repositories',
     'versions.os': 'OS',
     'versions.baseURL': 'Base URL',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5fdb57c/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
index b496987..a203b5c 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
@@ -88,6 +88,7 @@ angular.module('ambariAdminConsole')
     },
 
     allPublicStackVersions: function() {
+      var self = this;
       var url = '/version_definitions?fields=VersionDefinition/stack_default,VersionDefinition/stack_repo_update_link_exists,operating_systems/repositories/Repositories/*,VersionDefinition/stack_services,VersionDefinition/repository_version'
+
         '&VersionDefinition/show_available=true';
       var deferred = $q.defer();
@@ -104,7 +105,6 @@ angular.module('ambariAdminConsole')
               stackNameVersion:  version.VersionDefinition.stack_name + '-' + version.VersionDefinition.stack_version,
               displayName: version.VersionDefinition.stack_name + '-' + version.VersionDefinition.repository_version.split('-')[0],
//HDP-2.3.4.0
               displayNameFull: version.VersionDefinition.stack_name + '-' + version.VersionDefinition.repository_version,
//HDP-2.3.4.0-23
-              editableDisplayName: version.VersionDefinition.repository_version.substring(4),
               isNonXMLdata: true,
               repositoryVersion: version.VersionDefinition.repository_version,
               stackNameRepositoryVersion: version.VersionDefinition.stack_name + '-' + version.VersionDefinition.repository_version,
@@ -112,6 +112,7 @@ angular.module('ambariAdminConsole')
               osList: version.operating_systems,
               updateObj: version
             };
+            self.setVersionNumberProperties(version.VersionDefinition.repository_version,
versionObj);
             //hard code to not show stack name box for ECS stack
             if (isNaN(versionObj.editableDisplayName.charAt(0))) {
               versionObj.isNonXMLdata = false;
@@ -144,6 +145,35 @@ angular.module('ambariAdminConsole')
       return deferred.promise;
     },
 
+    setVersionNumberProperties: function(version, versionObj) {
+      var length = version.split(".").length;
+      switch (length) {
+        //when the stackVersion is single digit e.g. "2"
+        case 1:
+           versionObj.pattern = "(0.0.0)";
+           versionObj.subVersionPattern = new RegExp(/^\d+\.\d+(-\d+)?\.\d+$/);
+           versionObj.editableDisplayName = "";
+           break;
+        //when the stackVersion has two digits e.g. "2.5"
+        case 2:
+           versionObj.pattern = "(0.0)";
+           versionObj.subVersionPattern = new RegExp(/^\d+\.\d+(-\d+)?$/);
+           versionObj.editableDisplayName = version.substring(4);
+           break;
+        //when the stackVersion has three digits e.g. "2.5.1"
+        case 3:
+           versionObj.pattern = "(0)";
+           versionObj.subVersionPattern = new RegExp(/^[0-9]\d*$/);
+           versionObj.editableDisplayName = "";
+           break;
+        default:
+           versionObj.pattern = "(0.0)";
+           versionObj.subVersionPattern = new RegExp(/^\d+\.\d+(-\d+)?$/);
+           versionObj.editableDisplayName = version.substring(4);
+           break;
+      }
+    },
+
     allRepos: function (filter, pagination) {
       var versionFilter = filter.version;
       var nameFilter = filter.name;

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5fdb57c/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
index fe08802..5122173 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
@@ -91,8 +91,8 @@
                 </span>
                 <span class="dot">.</span>
                 <div class="form-group" ng-class="{'has-error' : versionRegForm.version.$error.pattern}">
-                  <input class="form-control" name="version" type="text" ng-model="activeStackVersion.editableDisplayName"
ng-pattern="subversionPattern"
-                         placeholder="{{'versions.placeholder' | translate}}" ng-change="updateCurrentVersionInput()"
required/>
+                  <input class="form-control" name="version" type="text" ng-model="activeStackVersion.editableDisplayName"
ng-pattern="activeStackVersion.subVersionPattern"
+                         placeholder="{{'versions.placeholder' | translate: '{pattern: activeStackVersion.pattern}'}}"
ng-change="updateCurrentVersionInput()" required/>
                 </div>
                 <div class="text-danger" ng-show="versionRegForm.version.$error.pattern">
                   &nbsp{{'common.alerts.isInvalid' | translate: '{term: activeStackVersion.displayName}'}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5fdb57c/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackVersionsCreateCtrl_test.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackVersionsCreateCtrl_test.js
b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackVersionsCreateCtrl_test.js
index 81d3441..7dff7ad 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackVersionsCreateCtrl_test.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/stackVersions/StackVersionsCreateCtrl_test.js
@@ -30,7 +30,7 @@ describe('#Cluster', function () {
       it('1 digit', function() {
         var input = "1";
         var input2 = "11";
-        var regex = scope.subversionPattern;
+        var regex = /^\d+\.\d+(-\d+)?$/;
         expect(regex.test(input)).toBe(false);
         expect(regex.test(input2)).toBe(false);
       });
@@ -38,7 +38,7 @@ describe('#Cluster', function () {
       it('1 digit dot 1 digit', function() {
         var input = "1.2";
         var input2 = "1.22";
-        var regex = scope.subversionPattern;
+        var regex = /^\d+\.\d+(-\d+)?$/;
         expect(regex.test(input)).toBe(true);
         expect(regex.test(input2)).toBe(true);
       });
@@ -49,7 +49,7 @@ describe('#Cluster', function () {
         var input3 = "1.1-123";
         var invalidInput = "1.1-abcd";
         var invalidInput2 = "1.2.3";
-        var regex = scope.subversionPattern;
+        var regex = /^\d+\.\d+(-\d+)?$/;
         expect(regex.test(input)).toBe(true);
         expect(regex.test(input2)).toBe(true);
         expect(regex.test(input3)).toBe(true);


Mime
View raw message