You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2014/12/30 16:36:37 UTC
ambari git commit: AMBARI-8958. Alerts UI: add confirm password field
in Edit Notification popup. (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk b4c48c262 -> cef3f2ccb
AMBARI-8958. Alerts UI: add confirm password field in Edit Notification popup. (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cef3f2cc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cef3f2cc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cef3f2cc
Branch: refs/heads/trunk
Commit: cef3f2ccbca0532b16bf6bae7061ef1127f1b14b
Parents: b4c48c2
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Tue Dec 30 16:54:44 2014 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Tue Dec 30 17:08:15 2014 +0200
----------------------------------------------------------------------
.../manage_alert_notifications_controller.js | 23 +++++++++--
ambari-web/app/messages.js | 2 +
.../main/alerts/create_alert_notification.hbs | 18 +++++++--
...anage_alert_notifications_controller_test.js | 40 +++++++++++++++++++-
4 files changed, 76 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/cef3f2cc/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js b/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js
index 22584c5..2dd442e 100644
--- a/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js
+++ b/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js
@@ -89,9 +89,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.SMTPUseAuthentication'),
value: false,
defaultValue: false,
- inversedValue: function () {
- return !this.get('value');
- }.property('value')
+ invertedValue: Em.computed.not('value')
}),
SMTPUsername: {
label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.SMTPUsername'),
@@ -103,6 +101,11 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
value: '',
defaultValue: ''
},
+ retypeSMTPPassword: {
+ label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.retypeSMTPPassword'),
+ value: '',
+ defaultValue: ''
+ },
SMTPSTARTTLS: {
label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.SMTPSTARTTLS'),
value: false,
@@ -290,6 +293,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
inputFields.set('SMTPUseAuthentication.value', selectedAlertNotification.get('properties')['mail.smtp.auth']);
inputFields.set('SMTPUsername.value', selectedAlertNotification.get('properties')['ambari.dispatch.credential.username']);
inputFields.set('SMTPPassword.value', selectedAlertNotification.get('properties')['ambari.dispatch.credential.password']);
+ inputFields.set('retypeSMTPPassword.value', selectedAlertNotification.get('properties')['ambari.dispatch.credential.password']);
inputFields.set('SMTPSTARTTLS.value', selectedAlertNotification.get('properties')['mail.smtp.starttls.enable']);
inputFields.set('emailFrom.value', selectedAlertNotification.get('properties')['mail.smtp.from']);
inputFields.set('version.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.version']);
@@ -338,6 +342,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
this.emailFromValidation();
this.smtpPortValidation();
this.portValidation();
+ this.retypePasswordValidation();
},
isEmailMethodSelected: function () {
@@ -392,6 +397,18 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
}
}.observes('controller.inputFields.port.value'),
+ retypePasswordValidation: function () {
+ var passwordValue = this.get('controller.inputFields.SMTPPassword.value');
+ var retypePasswordValue = this.get('controller.inputFields.retypeSMTPPassword.value');
+ if (passwordValue !== retypePasswordValue) {
+ this.set('parentView.hasErrors', true);
+ this.set('controller.inputFields.retypeSMTPPassword.errorMsg', Em.I18n.t('alerts.notifications.error.retypePassword'));
+ } else {
+ this.set('parentView.hasErrors', false);
+ this.set('controller.inputFields.retypeSMTPPassword.errorMsg', null);
+ }
+ }.observes('controller.inputFields.retypeSMTPPassword.value', 'controller.inputFields.SMTPPassword.value'),
+
groupsSelectView: Em.Select.extend({
attributeBindings: ['disabled'],
http://git-wip-us.apache.org/repos/asf/ambari/blob/cef3f2cc/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 11dd203..9e34bfc 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -911,6 +911,7 @@ Em.I18n.translations = {
'alerts.notifications.error.email': 'Must be a valid email address',
'alerts.notifications.error.integer': 'Must be an integer',
+ 'alerts.notifications.error.retypePassword': 'Password confirmation must match password',
'alerts.notifications.addCustomPropertyPopup.header': 'Add Property',
'alerts.notifications.addCustomPropertyPopup.error.propertyExists': 'Custom Property with current name already exists',
@@ -1883,6 +1884,7 @@ Em.I18n.translations = {
'alerts.actions.manage_alert_notifications_popup.SMTPUseAuthentication':'Use authentication',
'alerts.actions.manage_alert_notifications_popup.SMTPUsername':'Username',
'alerts.actions.manage_alert_notifications_popup.SMTPPassword':'Password',
+ 'alerts.actions.manage_alert_notifications_popup.retypeSMTPPassword':'Password Confirmation',
'alerts.actions.manage_alert_notifications_popup.SMTPSTARTTLS':'Start TLS',
'alerts.actions.manage_alert_notifications_popup.emailFrom':'Email From',
'alerts.actions.manage_alert_notifications_popup.version':'Version',
http://git-wip-us.apache.org/repos/asf/ambari/blob/cef3f2cc/ambari-web/app/templates/main/alerts/create_alert_notification.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs
index 159eccc..451e3e1 100644
--- a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs
+++ b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs
@@ -149,7 +149,7 @@
<label class="control-label">{{controller.inputFields.SMTPUsername.label}}</label>
<div class="controls">
- {{view Em.TextField disabledBinding="controller.inputFields.SMTPUseAuthentication.inversedValue" valueBinding="controller.inputFields.SMTPUsername.value" class="input-xlarge"}}
+ {{view Em.TextField disabledBinding="controller.inputFields.SMTPUseAuthentication.invertedValue" valueBinding="controller.inputFields.SMTPUsername.value" class="input-xlarge"}}
</div>
</div>
@@ -157,7 +157,19 @@
<label class="control-label">{{controller.inputFields.SMTPPassword.label}}</label>
<div class="controls">
- {{view Em.TextField type="password" disabledBinding="controller.inputFields.SMTPUseAuthentication.inversedValue" valueBinding="controller.inputFields.SMTPPassword.value" class="input-xlarge"}}
+ {{view Em.TextField type="password" disabledBinding="controller.inputFields.SMTPUseAuthentication.invertedValue" valueBinding="controller.inputFields.SMTPPassword.value" class="input-xlarge"}}
+ </div>
+ </div>
+
+ <div {{bindAttr class=":control-group controller.inputFields.retypeSMTPPassword.errorMsg:error"}}>
+ <label class="control-label">{{controller.inputFields.retypeSMTPPassword.label}}</label>
+
+ <div class="controls">
+ {{view Em.TextField type="password" disabledBinding="controller.inputFields.SMTPUseAuthentication.invertedValue" valueBinding="controller.inputFields.retypeSMTPPassword.value" class="input-xlarge"}}
+ </div>
+
+ <div class="controls error-msg">
+ {{controller.inputFields.retypeSMTPPassword.errorMsg}}
</div>
</div>
@@ -165,7 +177,7 @@
<label class="control-label" for="inputSMTPSTARTTLS">{{controller.inputFields.SMTPSTARTTLS.label}}</label>
<div class="controls">
- {{view Em.Checkbox disabledBinding="controller.inputFields.SMTPUseAuthentication.inversedValue" checkedBinding="controller.inputFields.SMTPSTARTTLS.value" id="inputSMTPSTARTTLS" class="input-xlarge"}}
+ {{view Em.Checkbox disabledBinding="controller.inputFields.SMTPUseAuthentication.invertedValue" checkedBinding="controller.inputFields.SMTPSTARTTLS.value" id="inputSMTPSTARTTLS" class="input-xlarge"}}
</div>
</div>
{{else}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/cef3f2cc/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index 47fcf38..831009c 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -234,6 +234,9 @@ describe('App.ManageAlertNotificationsController', function () {
SMTPPassword: {
value: ''
},
+ retypeSMTPPassword: {
+ value: ''
+ },
SMTPSTARTTLS: {
value: ''
},
@@ -301,6 +304,9 @@ describe('App.ManageAlertNotificationsController', function () {
SMTPPassword: {
value: 'pass'
},
+ retypeSMTPPassword: {
+ value: 'pass'
+ },
SMTPSTARTTLS: {
value: "true"
},
@@ -347,12 +353,17 @@ describe('App.ManageAlertNotificationsController', function () {
controller: Em.Object.create({
inputFields: {
global: {},
- allGroups: {}
+ allGroups: {},
+ SMTPPassword: {},
+ retypeSMTPPassword: {}
}
}),
groupSelect: Em.Object.create({
selection: [],
content: [{}, {}]
+ }),
+ parentView: Em.Object.create({
+ hasErrors: false
})
});
@@ -393,6 +404,33 @@ describe('App.ManageAlertNotificationsController', function () {
});
+ describe('#retypePasswordValidation', function () {
+
+ it('should check inputFields.retypeSMTPPassword.value', function () {
+
+ view.set('controller.inputFields.retypeSMTPPassword.errorMsg', null);
+ view.set('controller.inputFields.SMTPPassword.value', 'pass');
+ view.set('controller.inputFields.retypeSMTPPassword.value', 'pas');
+
+ expect(view.get('controller.inputFields.retypeSMTPPassword.errorMsg')).to.equal(Em.I18n.t('alerts.notifications.error.retypePassword'));
+ expect(view.get('parentView.hasErrors')).to.be.true;
+
+ });
+
+ it('should check inputFields.retypeSMTPPassword.value', function () {
+
+ view.set('parentView.hasErrors', true);
+ view.set('controller.inputFields.retypeSMTPPassword.errorMsg', 'error');
+ view.set('controller.inputFields.SMTPPassword.value', 'pass');
+ view.set('controller.inputFields.retypeSMTPPassword.value', 'pass');
+
+ expect(view.get('controller.inputFields.retypeSMTPPassword.errorMsg')).to.equal(null);
+ expect(view.get('parentView.hasErrors')).to.be.false;
+
+ });
+
+ });
+
});
});