Repository: ambari Updated Branches: refs/heads/trunk 3e6e9932c -> f0be765a1
AMBARI-15642. Refactor Alerts UI (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f0be765a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f0be765a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f0be765a Branch: refs/heads/trunk Commit: f0be765a15ea17e386b5fbc6cc9bc4968d9bcd5a Parents: 3e6e993 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Thu Mar 31 13:38:18 2016 +0300 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Thu Mar 31 13:38:18 2016 +0300 ---------------------------------------------------------------------- .../alert_definitions_actions_controller.js | 5 +- .../alerts/manage_alert_groups_controller.js | 73 +++++-------- .../manage_alert_notifications_controller.js | 106 +++++++++++-------- ambari-web/app/templates/common/modal_popup.hbs | 24 ++--- ...ustom_config_to_alert_notification_popup.hbs | 6 +- ambari-web/app/views/main/alerts.js | 3 - .../main/alerts/manage_alert_groups_view.js | 17 +-- .../alerts/manage_alert_notifications_view.js | 33 +++--- .../manage_alert_groups_controller_test.js | 48 --------- ...anage_alert_notifications_controller_test.js | 40 ------- .../manage_alert_notifications_view_test.js | 100 +---------------- 11 files changed, 128 insertions(+), 327 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js index 9241835..dc9f78c 100644 --- a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js +++ b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js @@ -168,10 +168,7 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({ return App.router.get('manageAlertGroupsController'); }.property('App.router.manageAlertGroupsController'), - updateButtons: function () { - var modified = this.get('subViewController.isDefsModified'); - this.set('disablePrimary', !modified); - }.observes('subViewController.isDefsModified'), + disablePrimary: Em.computed.not('subViewController.isDefsModified'), didInsertElement: function () { this.fitZIndex(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js index 9b22030..6ba5957 100644 --- a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js +++ b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js @@ -19,7 +19,6 @@ var App = require('app'); var validator = require('utils/validator'); -var numberUtils = require('utils/number_utils'); App.ManageAlertGroupsController = Em.Controller.extend({ @@ -111,13 +110,9 @@ App.ManageAlertGroupsController = Em.Controller.extend({ * Determines if some group was edited/created/deleted * @type {boolean} */ - isDefsModified: function () { - var modifiedGroups = this.get('defsModifiedAlertGroups'); - if (!this.get('isLoaded')) { - return false; - } - return !!(modifiedGroups.toSet.length || modifiedGroups.toCreate.length || modifiedGroups.toDelete.length); - }.property('defsModifiedAlertGroups'), + isDefsModified: Em.computed.and('isLoaded', 'isDefsModifiedAlertGroups'), + + isDefsModifiedAlertGroups: Em.computed.or('defsModifiedAlertGroups.toSet.length', 'defsModifiedAlertGroups.toCreate.length', 'defsModifiedAlertGroups.toDelete.length'), /** * Check when some config group was changed and updates <code>defsModifiedAlertGroups</code> once @@ -255,11 +250,9 @@ App.ManageAlertGroupsController = Em.Controller.extend({ default: group.get('default'), displayName: function () { var name = App.config.truncateGroupName(this.get('name')); - return this.get('default') ? (name + ' Default') : name; + return this.get('default') ? name + ' Default' : name; }.property('name', 'default'), - label: function () { - return this.get('displayName') + ' (' + this.get('definitions.length') + ')'; - }.property('displayName', 'definitions.length'), + label: Em.computed.format('{0} ({1})', 'displayName', 'definitions.length'), definitions: definitions, isAddDefinitionsDisabled: group.get('isAddDefinitionsDisabled'), notifications: targets @@ -615,8 +608,7 @@ App.ManageAlertGroupsController = Em.Controller.extend({ return; } var self = this; - var popup; - popup = App.ModalPopup.show({ + var popup = App.ModalPopup.show({ header: Em.I18n.t('alerts.actions.manage_alert_groups_popup.renameButton'), @@ -629,16 +621,14 @@ App.ManageAlertGroupsController = Em.Controller.extend({ */ alertGroupName: self.get('selectedAlertGroup.name'), - /** - * @type {string|null} - */ - warningMessage: null, + alertGroupNameIsEmpty: function () { + return !this.get('alertGroupName').trim().length; + }.property('alertGroupName'), /** - * New group name should be unique and valid - * @method validate + * @type {string|null} */ - validate: function () { + warningMessage: function () { var warningMessage = ''; var originalGroup = self.get('selectedAlertGroup'); var groupName = this.get('alertGroupName').trim(); @@ -656,20 +646,18 @@ App.ManageAlertGroupsController = Em.Controller.extend({ } } } - this.set('warningMessage', warningMessage); - }.observes('alertGroupName'), + return warningMessage; + }.property('alertGroupName'), /** * Primary button is disabled while user doesn't input valid group name * @type {boolean} */ - disablePrimary: function () { - return !(this.get('alertGroupName').trim().length > 0 && (this.get('warningMessage') !== null && !this.get('warningMessage'))); - }.property('warningMessage', 'alertGroupName'), + disablePrimary: Em.computed.or('alertGroupNameIsEmpty', 'warningMessage'), onPrimary: function () { self.set('selectedAlertGroup.name', this.get('alertGroupName')); - this.hide(); + this._super(); } }); @@ -698,21 +686,14 @@ App.ManageAlertGroupsController = Em.Controller.extend({ */ alertGroupName: duplicated ? self.get('selectedAlertGroup.name') + ' Copy' : "", - /** - * @type {string} - */ - warningMessage: '', - - didInsertElement: function () { - this._super(); - this.validate(); - }, + alertGroupNameIsEmpty: function () { + return !this.get('alertGroupName').trim().length; + }.property('alertGroupName'), /** - * alert group name should be unique and valid - * @method validate + * @type {string} */ - validate: function () { + warningMessage: function () { var warningMessage = ''; var groupName = this.get('alertGroupName').trim(); if (self.get('alertGroups').mapProperty('displayName').contains(groupName)) { @@ -723,16 +704,14 @@ App.ManageAlertGroupsController = Em.Controller.extend({ warningMessage = Em.I18n.t("form.validator.alertGroupName"); } } - this.set('warningMessage', warningMessage); - }.observes('alertGroupName'), + return warningMessage; + }.property('alertGroupName'), /** * Primary button is disabled while user doesn't input valid group name * @type {boolean} */ - disablePrimary: function () { - return !(this.get('alertGroupName').trim().length > 0 && !this.get('warningMessage')); - }.property('warningMessage', 'alertGroupName'), + disablePrimary: Em.computed.or('alertGroupNameIsEmpty', 'warningMessage'), onPrimary: function () { var newAlertGroup = Em.Object.create({ @@ -740,11 +719,9 @@ App.ManageAlertGroupsController = Em.Controller.extend({ default: false, displayName: function () { var name = App.config.truncateGroupName(this.get('name')); - return this.get('default') ? (name + ' Default') : name; + return this.get('default') ? name + ' Default' : name; }.property('name', 'default'), - label: function () { - return this.get('displayName') + ' (' + this.get('definitions.length') + ')'; - }.property('displayName', 'definitions.length'), + label: Em.computed.format('{0} ({1})', 'displayName', 'definitions.length'), definitions: duplicated ? self.get('selectedAlertGroup.definitions').slice(0) : [], notifications: self.get('alertGlobalNotifications'), isAddDefinitionsDisabled: false http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/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 6ce36ec..7dd7dea 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 @@ -61,9 +61,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ value: '', defaultValue: 'custom', disabled: false, - isAll: function () { - return this.get('value') == 'all'; - }.property('value') + isAll: Em.computed.equal('value', 'all') }), method: { label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.method'), @@ -203,6 +201,60 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ newCustomProperty: {name: '', value: ''}, /** + * Check if custom property name exists in the <code>inputFields.customProperties</code> + * + * @type {boolean} + */ + isNewCustomPropertyExists: function () { + return this.get('inputFields.customProperties').mapProperty('name').contains(this.get('newCustomProperty.name')); + }.property('newCustomProperty.name'), + + /** + * Check if custom property name exists in the <code>ignoredCustomProperties</code> + * + * @type {boolean} + */ + isNewCustomPropertyIgnored: function () { + return this.get('ignoredCustomProperties').contains(this.get('newCustomProperty.name')); + }.property('newCustomProperty.name'), + + /** + * Check if custom property name is valid according to the <code>validator.isValidConfigKey</code> + * + * @type {boolean} + */ + isNewCustomPropertyNameValid: function () { + return validator.isValidConfigKey(this.get('newCustomProperty.name')); + }.property('newCustomProperty.name'), + + /** + * Error message for the new custom property name + * + * @type {string} + */ + errorMessageForNewCustomPropertyName: function () { + var isNewCustomPropertyIgnored = this.get('isNewCustomPropertyIgnored'); + var isNewCustomPropertyExists = this.get('isNewCustomPropertyExists'); + var flag = this.get('isNewCustomPropertyNameValid'); + if (flag) { + if (isNewCustomPropertyExists || isNewCustomPropertyIgnored) { + return Em.I18n.t('alerts.notifications.addCustomPropertyPopup.error.propertyExists'); + } + } + else { + return Em.I18n.t('alerts.notifications.addCustomPropertyPopup.error.invalidPropertyName'); + } + return ''; + }.property('isNewCustomPropertyNameValid', 'isNewCustomPropertyExists', 'isNewCustomPropertyIgnored'), + + /** + * If some error with new custom property + * + * @type {boolean} + */ + isErrorWithNewCustomPropertyName: Em.computed.bool('errorMessageForNewCustomPropertyName'), + + /** * List custom property names that shouldn't be displayed on Edit page * @type {string[]} */ @@ -404,7 +456,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ validationMap = self.get('validationMap'); self.get('methods').forEach(function (method) { var validations = validationMap[method]; - if (method == currentMethod) { + if (method === currentMethod) { validations.mapProperty('validator').forEach(function (key) { this.get(key).call(this); }, this); @@ -428,7 +480,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ if (!newName) { this.set('nameError', true); errorMessage = Em.I18n.t('alerts.actions.manage_alert_notifications_popup.error.name.empty'); - } else if (newName && newName != this.get('currentName') && self.get('alertNotifications').mapProperty('name').contains(newName)) { + } else if (newName && newName !== this.get('currentName') && self.get('alertNotifications').mapProperty('name').contains(newName)) { this.set('nameError', true); errorMessage = Em.I18n.t('alerts.actions.manage_alert_notifications_popup.error.name.existed'); } else { @@ -485,7 +537,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ hostsValidation: function() { var inputValue = this.get('controller.inputFields.host.value').trim(), - hostError = false;; + hostError = false; if (!this.get('isEmailMethodSelected')) { var array = inputValue.split(','); hostError = array.some(function(hostname) { @@ -699,7 +751,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ properties: properties } }; - if (inputFields.get('allGroups.value') == 'custom') { + if (inputFields.get('allGroups.value') === 'custom') { apiObject.AlertTarget.groups = inputFields.get('groups.value').mapProperty('id'); } return apiObject; @@ -831,51 +883,17 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ return App.ModalPopup.show({ + controllerBinding: 'App.router.manageAlertNotificationsController', + header: Em.I18n.t('alerts.notifications.addCustomPropertyPopup.header'), primary: Em.I18n.t('common.add'), bodyClass: Em.View.extend({ - - /** - * If some error with new custom property - * @type {boolean} - */ - isError: false, - - controller: this, - - /** - * Error message for new custom property (invalid name, existed name etc) - * @type {string} - */ - errorMessage: '', - - /** - * Check new custom property for errors with its name - * @method errorHandler - */ - errorsHandler: function () { - var name = this.get('controller.newCustomProperty.name'); - var flag = validator.isValidConfigKey(name); - if (flag) { - if (this.get('controller.inputFields.customProperties').mapProperty('name').contains(name) || - this.get('controller.ignoredCustomProperties').contains(name)) { - this.set('errorMessage', Em.I18n.t('alerts.notifications.addCustomPropertyPopup.error.propertyExists')); - flag = false; - } - } - else { - this.set('errorMessage', Em.I18n.t('alerts.notifications.addCustomPropertyPopup.error.invalidPropertyName')); - } - this.set('isError', !flag); - this.set('parentView.disablePrimary', !flag); - }.observes('controller.newCustomProperty.name'), - templateName: require('templates/main/alerts/add_custom_config_to_alert_notification_popup') }), - disablePrimary: true, + disablePrimary: Em.computed.alias('controller.isErrorWithNewCustomPropertyName'), onPrimary: function () { self.addCustomProperty(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/templates/common/modal_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popup.hbs b/ambari-web/app/templates/common/modal_popup.hbs index 8559da5..77e37f0 100644 --- a/ambari-web/app/templates/common/modal_popup.hbs +++ b/ambari-web/app/templates/common/modal_popup.hbs @@ -20,31 +20,31 @@ <div class="modal-backdrop"></div> <div class="modal" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true"> <div class="modal-header"> - {{#if showCloseButton}} + {{#if view.showCloseButton}} <a class="close" {{action onClose target="view"}}>x</a> {{/if}} <h3 id="modal-label"> - {{#if headerClass}} - {{view headerClass}} + {{#if view.headerClass}} + {{view view.headerClass}} {{else}} - {{header}} + {{view.header}} {{/if}} </h3> </div> <div {{bindAttr class=":modal-body view.isHideBodyScroll:hidden-scroll"}}> - {{#if bodyClass}} - {{view bodyClass}} + {{#if view.bodyClass}} + {{view view.bodyClass}} {{else}} - {{#if encodeBody}} - {{body}} + {{#if view.encodeBody}} + {{view.body}} {{else}} - {{{body}}} + {{{view.body}}} {{/if}} {{/if}} </div> - {{#if showFooter}} - {{#if footerClass}} - {{view footerClass}} + {{#if view.showFooter}} + {{#if view.footerClass}} + {{view view.footerClass}} {{else}} <div class="modal-footer"> {{#if view.hasFooterCheckbox}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/templates/main/alerts/add_custom_config_to_alert_notification_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/alerts/add_custom_config_to_alert_notification_popup.hbs b/ambari-web/app/templates/main/alerts/add_custom_config_to_alert_notification_popup.hbs index 0033eac..701dfc1 100644 --- a/ambari-web/app/templates/main/alerts/add_custom_config_to_alert_notification_popup.hbs +++ b/ambari-web/app/templates/main/alerts/add_custom_config_to_alert_notification_popup.hbs @@ -17,7 +17,7 @@ }} <form class="form-horizontal alert-configs"> - <div {{bindAttr class="view.isError:error :control-group"}}> + <div {{bindAttr class="controller.isErrorWithNewCustomPropertyName:error :control-group"}}> <label class="control-label">{{t common.name}} </label> <div class="controls"> @@ -33,9 +33,9 @@ </div> </div> - {{#if view.isError}} + {{#if controller.isErrorWithNewCustomPropertyName}} <div class="alert alert-danger"> - {{view.errorMessage}} + {{controller.errorMessageForNewCustomPropertyName}} </div> {{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/views/main/alerts.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alerts.js b/ambari-web/app/views/main/alerts.js index 137f4a5..dc587a7 100644 --- a/ambari-web/app/views/main/alerts.js +++ b/ambari-web/app/views/main/alerts.js @@ -17,9 +17,6 @@ */ var App = require('app'); -var filters = require('views/common/filter_view'); -var sort = require('views/common/sort_view'); -var date = require('utils/date/date'); App.MainAlertsView = App.TableView.extend(App.TableServerViewMixin, { templateName:require('templates/main/alerts'), http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/views/main/alerts/manage_alert_groups_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alerts/manage_alert_groups_view.js b/ambari-web/app/views/main/alerts/manage_alert_groups_view.js index 068edd0..595328c 100644 --- a/ambari-web/app/views/main/alerts/manage_alert_groups_view.js +++ b/ambari-web/app/views/main/alerts/manage_alert_groups_view.js @@ -89,6 +89,11 @@ App.MainAlertsManageAlertGroupView = Em.View.extend({ }); }, + willDestroyElement: function () { + $("[rel='button-info']").tooltip('destroy'); + $("[rel='button-info-dropdown']").tooltip('destroy'); + }, + /** * Tooltip for "Add group"-button * @type {string} @@ -120,11 +125,11 @@ App.MainAlertsManageAlertGroupView = Em.View.extend({ addDefinitionTooltip: function () { if (this.get('controller.selectedAlertGroup.default')) { return Em.I18n.t('alerts.actions.manage_alert_groups_popup.addDefinitionToDefault'); - } else if (this.get('controller.selectedAlertGroup.isAddDefinitionsDisabled')) { + } + if (this.get('controller.selectedAlertGroup.isAddDefinitionsDisabled')) { return Em.I18n.t('alerts.actions.manage_alert_groups_popup.addDefinitionDisabled'); - } else { - return Em.I18n.t('alerts.actions.manage_alert_groups_popup.addDefinition'); } + return Em.I18n.t('alerts.actions.manage_alert_groups_popup.addDefinition'); }.property('controller.selectedAlertGroup.default', 'controller.selectedAlertGroup.isAddDefinitionsDisabled'), /** @@ -134,11 +139,11 @@ App.MainAlertsManageAlertGroupView = Em.View.extend({ removeDefinitionTooltip: function () { if (this.get('controller.selectedAlertGroup.default')) { return Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeDefinitionDisabled'); - } else if (this.get('controller.isDeleteDefinitionsDisabled')) { + } + if (this.get('controller.isDeleteDefinitionsDisabled')) { return Em.I18n.t('common.nothingToDelete'); - } else { - return Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeDefinition'); } + return Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeDefinition'); }.property('controller.selectedAlertGroup.default', 'controller.isDeleteDefinitionsDisabled') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js index 3f0bf2f..00d8e7b 100644 --- a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js +++ b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js @@ -29,27 +29,29 @@ App.ManageAlertNotificationsView = Em.View.extend({ selectedAlertNotificationGroups: function () { return this.get('controller.selectedAlertNotification.groups').toArray().mapProperty('displayName').join(', '); - }.property('controller.selectedAlertNotification', 'controller.selectedAlertNotification.groups.@each', 'controller.isLoaded'), + }.property('controller.selectedAlertNotification', 'controller.selectedAlertNotification.groups.@each.displayName', 'controller.isLoaded'), + + someAlertNotificationIsSelected: Em.computed.bool('controller.selectedAlertNotification'), /** * @type {boolean} */ - isAddButtonDisabled: true, + isAddButtonDisabled: Em.computed.alias('App.isOperator'), /** * @type {boolean} */ - isEditButtonDisabled: true, + isEditButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', 'App.isOperator'), /** * @type {boolean} */ - isRemoveButtonDisabled: true, + isRemoveButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', 'App.isOperator'), /** * @type {boolean} */ - isDuplicateButtonDisabled: true, + isDuplicateButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', 'App.isOperator'), /** * Show EMAIL information if selected alert notification has type EMAIL @@ -75,18 +77,6 @@ App.ManageAlertNotificationsView = Em.View.extend({ }.property('controller.selectedAlertNotification.alertStates'), /** - * Enable/disable "edit"/"remove"/"duplicate" buttons basing on <code>controller.selectedAlertNotification</code> - * @method buttonObserver - */ - buttonObserver: function () { - var selectedAlertNotification = this.get('controller.selectedAlertNotification'); - this.set('isAddButtonDisabled', (!selectedAlertNotification || App.isOperator)); - this.set('isEditButtonDisabled', (!selectedAlertNotification || App.isOperator)); - this.set('isRemoveButtonDisabled', (!selectedAlertNotification || App.isOperator)); - this.set('isDuplicateButtonDisabled', (!selectedAlertNotification || App.isOperator)); - }.observes('controller.selectedAlertNotification'), - - /** * Prevent user select more than 1 alert notification * @method onAlertNotificationSelect */ @@ -110,11 +100,7 @@ App.ManageAlertNotificationsView = Em.View.extend({ var notifications = this.get('controller.alertNotifications'); if (notifications && notifications.length) { this.set('selectedAlertNotification', this.get('controller.selectedAlertNotification') || notifications[0]); - this.buttonObserver(); } else { - if (!App.isOperator) { - this.set('isAddButtonDisabled', false); - } this.set('selectedAlertNotification', null); } Em.run.later(this, function () { @@ -124,6 +110,11 @@ App.ManageAlertNotificationsView = Em.View.extend({ } }.observes('controller.isLoaded'), + willDestroyElement: function () { + this.$("[rel='button-info']").tooltip('destroy'); + this.$("[rel='button-info-dropdown']").tooltip('destroy'); + }, + willInsertElement: function () { this.get('controller').loadAlertNotifications(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js index db0f50a..45c2a4c 100644 --- a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js @@ -32,29 +32,6 @@ describe('App.ManageAlertGroupsController', function () { App.TestAliases.testAsComputedFilterBy(getController(), 'alertGlobalNotifications', 'alertNotifications', 'global', true); - describe('#addAlertGroup', function () { - - beforeEach(function () { - manageAlertGroupsController.addAlertGroup(); - }); - - describe("#validate", function () { - it("should display no warning if user inputs valid characters into group name", function () { - - manageAlertGroupsController.addGroupPopup.set('alertGroupName', 'test'); - - expect(manageAlertGroupsController.addGroupPopup.warningMessage).to.be.empty; - }); - - it("should display warning if user inputs invalid characters into group name", function () { - manageAlertGroupsController.addGroupPopup.set('alertGroupName', '/{"!@#$%'); - - expect(manageAlertGroupsController.addGroupPopup.warningMessage).to.equal('Invalid Alert Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.'); - }); - - }); - }); - describe('#duplicateAlertGroup', function () { beforeEach(function () { var group = Ember.Object.create({ @@ -74,31 +51,6 @@ describe('App.ManageAlertGroupsController', function () { }); }); - describe('#renameAlertGroup', function () { - beforeEach(function () { - var group = Ember.Object.create({ - name: 'test' - }); - - manageAlertGroupsController.set('selectedAlertGroup', group); - manageAlertGroupsController.renameAlertGroup(); - }); - - describe("#validate", function () { - it("should display no warning if user inputs valid characters into group name", function () { - manageAlertGroupsController.renameGroupPopup.set('alertGroupName', 'hello'); - - expect(manageAlertGroupsController.renameGroupPopup.warningMessage).to.be.empty; - }); - - it("should display warning if user inputs invalid characters into group name", function () { - manageAlertGroupsController.renameGroupPopup.set('alertGroupName', '/{"!@#$%'); - - expect(manageAlertGroupsController.renameGroupPopup.warningMessage).to.equal('Invalid Alert Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.'); - }); - }); - }); - describe('#deleteDefinitions', function () { var definitions = [ Em.Object.create({ http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/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 57f799f..837c2f3 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 @@ -1169,46 +1169,6 @@ describe('App.ManageAlertNotificationsController', function () { }); - describe('#bodyClass', function () { - - var view; - - beforeEach(function () { - view = controller.addCustomPropertyHandler().get('bodyClass').create({ - parentView: Em.View.create(), - controller: Em.Object.create({ - inputFields: Em.Object.create({ - customProperties: [ - {name: 'n1', value: 'v1', defaultValue: 'v1'} - ] - }), - newCustomProperty: {name: '', value: ''} - }) - }); - }); - - describe('#errorHandler', function () { - - it('should fire invalid name', function () { - view.set('controller.newCustomProperty.name', '!!'); - view.errorsHandler(); - expect(view.get('isError')).to.be.true; - expect(view.get('parentView.disablePrimary')).to.be.true; - expect(view.get('errorMessage.length')).to.be.above(0); - }); - - it('should fire existing property name', function () { - view.set('controller.newCustomProperty.name', 'n1'); - view.errorsHandler(); - expect(view.get('isError')).to.be.true; - expect(view.get('parentView.disablePrimary')).to.be.true; - expect(view.get('errorMessage.length')).to.be.above(0); - }); - - }); - - }); - }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be765a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js index 63382bd..cebee96 100644 --- a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js +++ b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js @@ -30,96 +30,6 @@ describe('App.ManageAlertNotificationsView', function () { }); - describe('#buttonObserver', function () { - - Em.A([ - { - isOperator: false, - selectedAlertNotification: {id: 1}, - m: 'some alert notification is selected and user is an admin', - p: { - isAddButtonDisabled: true, - isEditButtonDisabled: true, - isRemoveButtonDisabled: true, - isDuplicateButtonDisabled: true - }, - e: { - isAddButtonDisabled: false, - isEditButtonDisabled: false, - isRemoveButtonDisabled: false, - isDuplicateButtonDisabled: false - } - }, - { - isOperator: true, - selectedAlertNotification: {id: 1}, - m: 'some alert notification is selected and user is a non-admin operator', - p: { - isAddButtonDisabled: true, - isEditButtonDisabled: true, - isRemoveButtonDisabled: true, - isDuplicateButtonDisabled: true - }, - e: { - isAddButtonDisabled: true, - isEditButtonDisabled: true, - isRemoveButtonDisabled: true, - isDuplicateButtonDisabled: true - } - }, - { - isOperator: false, - selectedAlertNotification: null, - m: 'some alert notification is not selected and user is an admin', - p: { - isAddButtonDisabled: true, - isEditButtonDisabled: false, - isRemoveButtonDisabled: false, - isDuplicateButtonDisabled: false - }, - e: { - isAddButtonDisabled: true, - isEditButtonDisabled: true, - isRemoveButtonDisabled: true, - isDuplicateButtonDisabled: true - } - }, - { - isOperator: true, - selectedAlertNotification: null, - m: 'some alert notification is not selected and user is a non-admin operator', - p: { - isAddButtonDisabled: true, - isEditButtonDisabled: false, - isRemoveButtonDisabled: false, - isDuplicateButtonDisabled: false - }, - e: { - isAddButtonDisabled: true, - isEditButtonDisabled: true, - isRemoveButtonDisabled: true, - isDuplicateButtonDisabled: true - } - } - ]).forEach(function (test) { - describe(test.m, function () { - beforeEach(function () { - view.setProperties(test.p); - view.set('controller.selectedAlertNotification', test.selectedAlertNotification); - App.isOperator = test.isOperator; - view.buttonObserver(); - }); - - Em.keys(test.e).forEach(function (k) { - it(k, function () { - expect(view.get(k)).to.equal(test.e[k]); - }); - }); - }); - }); - - }); - describe('#showEmailDetails', function () { Em.A([ @@ -274,7 +184,6 @@ describe('App.ManageAlertNotificationsView', function () { beforeEach(function () { view.removeObserver('controller.isLoaded', view, 'onLoad'); view.set('controller', Em.Object.create()); - sinon.stub(view, 'buttonObserver'); sinon.stub(Em.run, 'later', function (context, callback) { callback(); }); @@ -282,7 +191,6 @@ describe('App.ManageAlertNotificationsView', function () { this.clock = sinon.useFakeTimers(); }); afterEach(function () { - view.buttonObserver.restore(); Em.run.later.restore(); App.tooltip.restore(); this.clock.restore(); @@ -319,14 +227,14 @@ describe('App.ManageAlertNotificationsView', function () { it("isAddButtonDisabled should be true", function () { view.set('isAddButtonDisabled', true); - App.isOperator = true; + App.set('isOperator', true); view.onLoad(); expect(view.get('isAddButtonDisabled')).to.be.true; }); it("isAddButtonDisabled should be false", function () { view.set('isAddButtonDisabled', true); - App.isOperator = false; + App.set('isOperator', false); view.onLoad(); expect(view.get('isAddButtonDisabled')).to.be.false; }); @@ -355,10 +263,6 @@ describe('App.ManageAlertNotificationsView', function () { expect(view.get('selectedAlertNotification')).to.eql({}); }); - it("buttonObserver should be called", function () { - view.onLoad(); - expect(view.buttonObserver.calledOnce).to.be.true; - }); }); }); });