You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/10/27 13:43:48 UTC

[1/2] ambari git commit: AMBARI-13567. Kerb: credential dialog should not allow empty princ/pwd

Repository: ambari
Updated Branches:
  refs/heads/trunk bd7d61d5b -> c1312ee78


AMBARI-13567. Kerb: credential dialog should not allow empty princ/pwd


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

Branch: refs/heads/trunk
Commit: c1312ee78d2e4a93502d87b2e259d4af70888169
Parents: 17d6d8a
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue Oct 27 14:29:47 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Tue Oct 27 14:43:44 2015 +0200

----------------------------------------------------------------------
 .../common/form/manage_credentilas_form.hbs     | 10 ++++
 .../common/form/manage_credentials_form_view.js | 51 ++++++++++++++++++--
 .../form/manage_kdc_credentials_form_test.js    | 24 +++++++++
 3 files changed, 82 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c1312ee7/ambari-web/app/templates/common/form/manage_credentilas_form.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/form/manage_credentilas_form.hbs b/ambari-web/app/templates/common/form/manage_credentilas_form.hbs
index 71f44ee..26ded49 100644
--- a/ambari-web/app/templates/common/form/manage_credentilas_form.hbs
+++ b/ambari-web/app/templates/common/form/manage_credentilas_form.hbs
@@ -24,12 +24,22 @@
     <label class="control-label">{{t popup.invalid.KDC.admin.principal}}</label>
     <div class="controls">
       {{view Ember.TextField valueBinding="view.principal" class="form-control"}}
+      {{#if view.principalError}}
+        <p class="mtm text-error">
+          {{view.principalError}}
+        </p>
+      {{/if}}
     </div>
   </div>
   <div class="control-group">
     <label class="control-label">{{t popup.invalid.KDC.admin.password}}</label>
     <div class="controls">
       {{view Ember.TextField type="password" valueBinding="view.password" class="form-control"}}
+      {{#if view.passwordError}}
+        <p class="mtm text-error">
+          {{view.passwordError}}
+        </p>
+      {{/if}}
     </div>
   </div>
 </form>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1312ee7/ambari-web/app/views/common/form/manage_credentials_form_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/form/manage_credentials_form_view.js b/ambari-web/app/views/common/form/manage_credentials_form_view.js
index 3327d0d..685051d 100644
--- a/ambari-web/app/views/common/form/manage_credentials_form_view.js
+++ b/ambari-web/app/views/common/form/manage_credentials_form_view.js
@@ -75,9 +75,54 @@ App.ManageCredentialsFormView = Em.View.extend({
    */
   actionStatus: false,
 
-  isSubmitDisabled: function() {
-    return Em.isEmpty(this.get('principal')) || Em.isEmpty(this.get('password'));
-  }.property('principal', 'password'),
+  /**
+   * Validation message error regarding principal name.
+   * When value is <code>false</code> error is hidden.
+   *
+   * @type {boolean|string}
+   */
+  passwordError: false,
+
+  /**
+   * Validation message error regarding principal name field.
+   * When value is <code>false</code> error is hidden.
+   *
+   * @type {boolean|string}
+   */
+  principalError: false,
+
+  isSubmitDisabled: true,
+
+  principalNameObserver: function() {
+    this.set('isPrincipalDirty', true);
+    if (Em.isEmpty(this.get('principal'))) {
+      this.set('principalError', Em.I18n.t('admin.users.editError.requiredField'));
+    } else if (/\s+/.test(this.get('principal'))) {
+      this.set('principalError', Em.I18n.t('host.spacesValidation'));
+    } else {
+      this.set('principalError', false);
+    }
+    this.toggleSubmitState();
+  }.observes('principal'),
+
+  passwordObserver: function() {
+    this.set('isPasswordDirty', true);
+    if (Em.isEmpty(this.get('password'))) {
+      this.set('passwordError', Em.I18n.t('admin.users.editError.requiredField'));
+    } else {
+      this.set('passwordError', false);
+    }
+    this.toggleSubmitState();
+  }.observes('password'),
+
+  /**
+   * Toggle submit disable state only when principal and password fields were modified.
+   */
+  toggleSubmitState: function() {
+    if (this.get('isPrincipalDirty') && this.get('isPasswordDirty')) {
+      this.set('isSubmitDisabled', !!this.get('principalError') || !!this.get('passwordError'));
+    }
+  },
 
   /**
    * Returns storage type used to save credentials e.g. <b>persistent</b>, <b>temporary</b> (default)

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1312ee7/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
index 1cba71c..76b6763 100644
--- a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
+++ b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
@@ -102,6 +102,30 @@ describe('#App.ManageCredentialsFormView', function() {
     });
   });
 
+  describe('fields validation', function() {
+    it('should flow validation', function() {
+      var t = Em.I18n.t;
+      assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled on initial state');
+      view.set('principal', ' a');
+      assert.equal(view.get('principalError'), t('host.spacesValidation'), 'principal contains spaces, appropriate message shown');
+      assert.isTrue(view.get('isPrincipalDirty'), 'principal name modified');
+      assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled because principal not valid');
+      view.set('principal', '');
+      assert.equal(view.get('principalError'), t('admin.users.editError.requiredField'), 'principal is empty, appropriate message shown');
+      view.set('principal', 'some_name');
+      assert.isFalse(view.get('principalError'), 'principal name valid no message shown');
+      assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled because password field not modified');
+      view.set('password', '1');
+      view.set('password', '');
+      assert.equal(view.get('passwordError'), t('admin.users.editError.requiredField'), 'password is empty, appropriate message shown');
+      assert.isTrue(view.get('isPasswordDirty'), 'password modified');
+      assert.isTrue(view.get('isSubmitDisabled'), 'submit disabled because password field is empty');
+      view.set('password', 'some_pass');
+      assert.isFalse(view.get('passwordError'), 'password valid no message shown');
+      assert.isFalse(view.get('isSubmitDisabled'), 'submit enabled all fields are valid');
+    });
+  });
+
   describe('#removeKDCCredentials', function() {
     it('should show confirmation popup', function() {
       var popup = view.removeKDCCredentials().popup;


[2/2] ambari git commit: AMBARI-13579. Wrong sorting icons on config history page

Posted by al...@apache.org.
AMBARI-13579. Wrong sorting icons on config history page


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

Branch: refs/heads/trunk
Commit: 17d6d8a59001e865ea31a2a06cfb93295f772963
Parents: bd7d61d
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue Oct 27 14:21:52 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Tue Oct 27 14:43:44 2015 +0200

----------------------------------------------------------------------
 .../app/views/main/dashboard/config_history_view.js   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/17d6d8a5/ambari-web/app/views/main/dashboard/config_history_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/config_history_view.js b/ambari-web/app/views/main/dashboard/config_history_view.js
index 7cc95a3..5244422 100644
--- a/ambari-web/app/views/main/dashboard/config_history_view.js
+++ b/ambari-web/app/views/main/dashboard/config_history_view.js
@@ -40,6 +40,19 @@ App.MainConfigHistoryView = App.TableView.extend(App.TableServerViewMixin, {
     return this.t('tableView.filters.filteredConfigVersionInfo').format(this.get('filteredCount'), this.get('totalCount'));
   }.property('filteredCount', 'totalCount'),
 
+  willInsertElement: function () {
+    var
+      controllerName = this.get('controller.name'),
+      savedSortConditions = App.db.getSortingStatuses(controllerName) || [];
+
+    if (savedSortConditions && savedSortConditions.everyProperty('status', 'sorting')) {
+      savedSortConditions.push({
+        name: "createTime",
+        status: "sorting_desc"
+      });
+      App.db.setSortingStatuses(controllerName, savedSortConditions);
+    }
+  },
   didInsertElement: function () {
     this.addObserver('startIndex', this, 'updatePagination');
     this.addObserver('displayLength', this, 'updatePagination');
@@ -78,7 +91,6 @@ App.MainConfigHistoryView = App.TableView.extend(App.TableServerViewMixin, {
   modifiedSort: sort.fieldView.extend({
     column: 3,
     name: 'createTime',
-    status: 'sorting_desc',
     displayName: Em.I18n.t('dashboard.configHistory.table.created.title')
   }),
   authorSort: sort.fieldView.extend({