AMBARI-19231 Delete host component should show configs being changed in recommendation popup modal. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/195f3ce1 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/195f3ce1 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/195f3ce1 Branch: refs/heads/branch-dev-patch-upgrade Commit: 195f3ce164e6654b77813c412fe70fe240bb58c1 Parents: 61dcdc3 Author: ababiichuk <[email protected]> Authored: Mon Dec 19 09:00:37 2016 +0200 Committer: ababiichuk <[email protected]> Committed: Mon Dec 19 12:13:32 2016 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 418 ++++++++++--------- ambari-web/app/messages.js | 7 - .../main/host/details/addComponentPopup.hbs | 19 - .../details/addComponentWithConfigsChanges.hbs | 27 -- .../host/details/addDeleteComponentPopup.hbs | 40 ++ .../main/host/details/deleteComponentPopup.hbs | 45 -- ambari-web/app/views/main/host/summary.js | 4 - .../test/controllers/main/host/details_test.js | 223 +++------- 8 files changed, 310 insertions(+), 473 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index 3a5dca5..5f2af2c 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -75,6 +75,67 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow isConfigsLoaded: false, + addDeleteComponentsMap: { + 'ZOOKEEPER_SERVER': { + deletePropertyName: 'fromDeleteZkServer', + configsCallbackName: 'loadStormConfigs' + }, + 'HIVE_METASTORE': { + deletePropertyName: 'deleteHiveMetaStore', + hostPropertyName: 'hiveMetastoreHost', + configsCallbackName: 'loadHiveConfigs' + }, + 'WEBHCAT_SERVER': { + deletePropertyName: 'deleteWebHCatServer', + hostPropertyName: 'webhcatServerHost', + configsCallbackName: 'loadWebHCatConfigs' + }, + 'HIVE_SERVER': { + deletePropertyName: 'deleteHiveServer', + hostPropertyName: '', + configsCallbackName: 'loadHiveConfigs' + }, + 'NIMBUS': { + deletePropertyName: 'deleteNimbusHost', + hostPropertyName: 'nimbusHost', + configsCallbackName: 'loadStormConfigs' + }, + 'RANGER_KMS_SERVER': { + deletePropertyName: 'deleteRangerKMSServer', + hostPropertyName: 'rangerKMSServerHost', + configsCallbackName: 'loadRangerConfigs' + } + }, + + addDeleteComponentPopupBody: Em.View.extend({ + templateName: require('templates/main/host/details/addDeleteComponentPopup'), + isReconfigure: false, + commonMessage: '', + manualKerberosWarning: App.get('router.mainAdminKerberosController.isManualKerberos') ? + Em.I18n.t('hosts.host.manualKerberosWarning') : '', + propertiesToChange: [], + lastComponent: false, + lastComponentError: '', + setPopupSize: function () { + this.set('parentView.hasPropertiesToChange', !!this.get('propertiesToChange.length')); + }.observes('propertiesToChange.length') + }), + + applyConfigsCustomization: function (configs) { + configs.propertiesToChange.forEach(function (property) { + var value = property.saveRecommended ? property.recommendedValue : property.initialValue, + filename = property.propertyFileName; + if (configs.groups.length) { + var group = configs.groups.find(function (item) { + return item.properties.hasOwnProperty(filename); + }); + if (group) { + group.properties[filename][property.propertyName] = value; + } + } + }); + }, + /** * Open dashboard page * @method routeHome @@ -316,47 +377,84 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow var component = event.context; var componentName = component.get('componentName'); var displayName = component.get('displayName'); - var isLastComponent = (this.getTotalComponent(component) === 1); + var hostName = event.selectedHost || this.get('content.hostName'); + var returnFunc; + var componentsMapItem = this.get('addDeleteComponentsMap')[componentName]; + if (componentsMapItem) { + var primary; + if (componentsMapItem.deletePropertyName) { + this.set(componentsMapItem.deletePropertyName, true); + } + if (componentName === 'ZOOKEEPER_SERVER') { + primary = function () { + this.set('fromDeleteZkServer', true); + this.updateStormConfigs(); + this.isServiceMetricsLoaded(function () { + self.loadConfigs(); + }); + } + } + returnFunc = this.showDeleteComponentPopup(component, true, componentsMapItem.configsCallbackName, primary); + } else if (componentName === 'JOURNALNODE') { + returnFunc = App.showConfirmationPopup(function () { + App.router.transitionTo('main.services.manageJournalNode'); + }, Em.I18n.t('hosts.host.deleteComponent.popup.deleteJournalNodeMsg')); + } else { + returnFunc = this.showDeleteComponentPopup(component); + } + return returnFunc; + }, + + showDeleteComponentPopup: function (component, isReconfigure, callbackName, primary) { + var self = this, + isLastComponent = (this.getTotalComponent(component) === 1), + componentName = component.get('componentName'), + componentDisplayName = component.get('displayName'), + commonMessage = Em.I18n.t('hosts.host.deleteComponent.popup.msg1').format(componentDisplayName); + if (isReconfigure) { + var configs = { + groups: [], + propertiesToChange: [] + }; + this.loadConfigs(callbackName, configs); + } return App.ModalPopup.show({ header: Em.I18n.t('popup.confirmation.commonHeader'), - primary: componentName == 'JOURNALNODE'? Em.I18n.t('ok') : Em.I18n.t('hosts.host.deleteComponent.popup.confirm'), - bodyClass: Em.View.extend({ - templateName: require('templates/main/host/details/deleteComponentPopup') + controller: self, + hasPropertiesToChange: false, + classNameBindings: ['hasPropertiesToChange:common-modal-wrapper', 'hasPropertiesToChange:modal-full-width'], + modalDialogClasses: function () { + return this.get('hasPropertiesToChange') ? ['modal-lg'] : []; + }.property('hasPropertiesToChange'), + primary: Em.I18n.t('hosts.host.deleteComponent.popup.confirm'), + bodyClass: self.get('addDeleteComponentPopupBody').extend({ + isReconfigure: isReconfigure, + commonMessage: commonMessage, + propertiesToChange: isReconfigure ? configs.propertiesToChange : [], + lastComponentError: Em.I18n.t('hosts.host.deleteComponent.popup.warning').format(componentDisplayName), + lastComponent: function () { + this.set('parentView.isChecked', !isLastComponent); + return isLastComponent; + }.property() }), - isHiveMetastore: componentName == 'HIVE_METASTORE', - isWebHCatServer: componentName == 'WEBHCAT_SERVER', - isNimbus: componentName == 'NIMBUS', - isRangerKMSServer: componentName == 'RANGER_KMS_SERVER', - isZkServer: componentName == 'ZOOKEEPER_SERVER', - isJournalNode: componentName == 'JOURNALNODE', - - deleteHiveMetastoreMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteHiveMetastore'), - deleteWebHCatServerMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteWebHCatServer'), - deleteNimbusMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteNimbus'), - deleteRangerKMSServereMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteRangerKMSServer'), - lastComponentError: Em.I18n.t('hosts.host.deleteComponent.popup.warning').format(displayName), - deleteComponentMsg: Em.I18n.t('hosts.host.deleteComponent.popup.msg1').format(displayName), - deleteZkServerMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteZooKeeperServer'), - deleteJournalNodeMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteJournalNodeMsg'), - isChecked: false, - disablePrimary: Em.computed.not('isChecked'), - lastComponent: function () { - this.set('isChecked', !isLastComponent); - return isLastComponent; - }.property(), - + disablePrimary: function () { + return (isReconfigure && !this.get('controller.isConfigsLoaded')) || !this.get('isChecked'); + }.property('controller.isConfigsLoaded', 'isChecked'), onPrimary: function () { - var popup = this; - if (componentName == 'JOURNALNODE') { - popup.hide(); - App.router.transitionTo('main.services.manageJournalNode'); - } else { - self._doDeleteHostComponent(component, function () { - self.set('redrawComponents', true); - popup.hide(); - }); + this._super(); + if (isReconfigure) { + self.applyConfigsCustomization(configs); } + self._doDeleteHostComponent(componentName, function () { + if (isReconfigure) { + self.saveConfigsBatch(configs.groups, componentName); + if (primary) { + primary.call(self); + } + } + self.set('redrawComponents', true); + }); } }); }, @@ -394,13 +492,13 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * when components failed to get deleted. * @method _doDeleteHostComponent */ - _doDeleteHostComponent: function (component, callback) { + _doDeleteHostComponent: function (componentName, callback) { callback = callback || Em.K; App.ajax.send({ - name: (Em.isNone(component)) ? 'common.delete.host' : 'common.delete.host_component', + name: (Em.isNone(componentName)) ? 'common.delete.host' : 'common.delete.host_component', sender: this, data: { - componentName: (component) ? component.get('componentName') : '', + componentName: componentName || '', hostName: this.get('content.hostName') }, success: '_doDeleteHostComponentSuccessCallback', @@ -419,31 +517,8 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method _doDeleteHostComponentSuccessCallback */ _doDeleteHostComponentSuccessCallback: function (response, request, data) { - var self = this; this.set('_deletedHostComponentResult', null); this.removeHostComponentModel(data.componentName, data.hostName); - if (data.componentName == 'ZOOKEEPER_SERVER') { - this.set('fromDeleteZkServer', true); - this.updateStormConfigs(); - self.isServiceMetricsLoaded(function () { - self.loadConfigs(); - }); - } else if (data.componentName == 'HIVE_METASTORE') { - this.set('deleteHiveMetaStore', true); - this.loadConfigs('loadHiveConfigs'); - } else if (data.componentName == 'WEBHCAT_SERVER') { - this.set('deleteWebHCatServer', true); - this.loadConfigs('loadWebHCatConfigs'); - } else if (data.componentName == 'HIVE_SERVER') { - this.set('deleteHiveServer', true); - this.loadConfigs('loadHiveConfigs'); - } else if (data.componentName == 'NIMBUS') { - this.set('deleteNimbusHost', true); - this.loadConfigs('loadStormConfigs'); - } else if (data.componentName == 'RANGER_KMS_SERVER') { - this.set('deleteRangerKMSServer', true); - this.loadConfigs('loadRangerConfigs'); - } }, /** @@ -538,55 +613,6 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow } }, - showAddComponentConfirmation: function (componentName, callbackName, primary) { - var self = this, - componentDisplayName = App.format.role(componentName, false), - manualKerberosWarning = App.get('router.mainAdminKerberosController.isManualKerberos') ? - Em.I18n.t('hosts.host.manualKerberosWarning') : '', - commonMessage = Em.I18n.t('hosts.host.addComponent.msg').format(componentDisplayName), - configs = { - groups: [], - propertiesToChange: [] - }; - this.loadConfigs(callbackName, configs); - App.ModalPopup.show({ - header: Em.I18n.t('popup.confirmation.commonHeader'), - controller: self, - hasPropertiesToChange: false, - classNameBindings: ['hasPropertiesToChange:common-modal-wrapper', 'hasPropertiesToChange:modal-full-width'], - modalDialogClasses: function () { - return this.get('hasPropertiesToChange') ? ['modal-lg'] : []; - }.property('hasPropertiesToChange'), - primary: Em.I18n.t('hosts.host.addComponent.popup.confirm'), - bodyClass: Em.View.extend({ - templateName: require('templates/main/host/details/addComponentWithConfigsChanges'), - commonMessage: commonMessage, - manualKerberosWarning: manualKerberosWarning, - propertiesToChange: configs.propertiesToChange, - setPopupSize: function () { - this.set('parentView.hasPropertiesToChange', !!this.get('propertiesToChange.length')); - }.observes('propertiesToChange.length') - }), - disablePrimary: Em.computed.not('controller.isConfigsLoaded'), - onPrimary: function () { - this._super(); - configs.propertiesToChange.forEach(function (property) { - var value = property.saveRecommended ? property.recommendedValue : property.initialValue, - filename = property.propertyFileName; - if (configs.groups.length) { - var group = configs.groups.find(function (item) { - return item.properties.hasOwnProperty(filename); - }); - group.properties[filename][property.propertyName] = value; - } - }); - if (primary) { - primary.call(self, configs.groups); - } - } - }); - }, - /** * add component as <code>addComponent<code> method but perform * kdc sessionstate if cluster is secure; @@ -616,7 +642,8 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow installedComponents: this.get('content.hostComponents').mapProperty('componentName') }), isManualKerberos = App.get('router.mainAdminKerberosController.isManualKerberos'), - manualKerberosWarning = isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : ''; + manualKerberosWarning = isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : '', + componentsMapItem = this.get('addDeleteComponentsMap')[componentName]; if (!!missedComponents.length) { var popupMessage = Em.I18n.t('host.host.addComponent.popup.dependedComponents.body').format(component.get('displayName'), @@ -626,110 +653,74 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow return App.showAlertPopup(Em.I18n.t('host.host.addComponent.popup.dependedComponents.header'), popupMessage); } - switch (componentName) { - case 'ZOOKEEPER_SERVER': - returnFunc = self.showAddComponentConfirmation(componentName, null, function (groups) { - this.saveConfigsBatch(groups, componentName, hostName); - }); - break; - case 'HIVE_METASTORE': - self.set('hiveMetastoreHost', hostName); - returnFunc = self.showAddComponentConfirmation(componentName, 'loadHiveConfigs', function (groups) { - this.saveConfigsBatch(groups, componentName, hostName); + if (componentsMapItem) { + var primary; + if (componentsMapItem.hostPropertyName) { + this.set(componentsMapItem.hostPropertyName, hostName); + } + if (componentName === 'HIVE_METASTORE') { + primary = function () { this.set('addHiveServer', false); - }); - break; - case 'WEBHCAT_SERVER': - self.set('webhcatServerHost', hostName); - returnFunc = self.showAddComponentConfirmation(componentName, 'loadWebHCatConfigs', function (groups) { - this.saveConfigsBatch(groups, componentName, hostName); - }); - break; - case 'NIMBUS': - self.set('nimbusHost', hostName); - returnFunc = self.showAddComponentConfirmation(componentName, 'loadStormConfigs', function (groups) { - this.saveConfigsBatch(groups, componentName, hostName); - }); - break; - case 'RANGER_KMS_SERVER': - self.set('rangerKMSServerHost', hostName); - returnFunc = self.showAddComponentConfirmation(componentName, 'loadRangerConfigs', function (groups) { - this.saveConfigsBatch(groups, componentName, hostName); - }); - break; - case 'JOURNALNODE': - returnFunc = App.showConfirmationPopup(function () { - App.router.transitionTo('main.services.manageJournalNode'); - }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning); - break; - default: - returnFunc = this.addClientComponent(component, isManualKerberos); + }; + } + returnFunc = self.showAddComponentPopup(component, hostName, null, true, componentsMapItem.configsCallbackName, primary); + } else if (componentName === 'JOURNALNODE') { + returnFunc = App.showConfirmationPopup(function () { + App.router.transitionTo('main.services.manageJournalNode'); + }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning); + } else { + returnFunc = this.showAddComponentPopup(component, hostName, function () { + self.installHostComponentCall(hostName, component); + }); } return returnFunc; }, - /** - * Send command to server to install client on selected host - * @param {App.HostComponent} component - * @param {boolean} isManualKerberos - * @returns {*} - */ - addClientComponent: function (component, isManualKerberos) { + showAddComponentPopup: function (component, hostName, primary, isReconfigure, callbackName, primaryOnReconfigure) { var self = this, - displayName = this.formatClientsMessage(component); - - return this.showAddComponentPopup(displayName, isManualKerberos, function () { - self.installHostComponentCall(self.get('content.hostName'), component); - }); - }, - - /** - * - * @param {string} displayName - * @param {boolean} isManualKerberos - * @param {Function} primary - * @returns {*} - */ - showAddComponentPopup: function (displayName, isManualKerberos, primary) { - isManualKerberos = isManualKerberos || false; - + componentName = component.get('componentName'), + componentDisplayName = component.get('displayName'), + commonMessage = Em.I18n.t('hosts.host.addComponent.msg').format(componentDisplayName); + if (isReconfigure) { + var configs = { + groups: [], + propertiesToChange: [] + }; + this.loadConfigs(callbackName, configs); + } return App.ModalPopup.show({ - primary: Em.I18n.t('hosts.host.addComponent.popup.confirm'), header: Em.I18n.t('popup.confirmation.commonHeader'), - - addComponentMsg: Em.I18n.t('hosts.host.addComponent.msg').format(displayName), - - manualKerberosWarning: isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : '', - - bodyClass: Em.View.extend({ - templateName: require('templates/main/host/details/addComponentPopup') + controller: self, + hasPropertiesToChange: false, + classNameBindings: ['hasPropertiesToChange:common-modal-wrapper', 'hasPropertiesToChange:modal-full-width'], + modalDialogClasses: function () { + return this.get('hasPropertiesToChange') ? ['modal-lg'] : []; + }.property('hasPropertiesToChange'), + primary: Em.I18n.t('hosts.host.addComponent.popup.confirm'), + bodyClass: self.get('addDeleteComponentPopupBody').extend({ + commonMessage: commonMessage, + isReconfigure: isReconfigure, + propertiesToChange: isReconfigure ? configs.propertiesToChange : [] }), - + disablePrimary: function () { + return isReconfigure && !this.get('controller.isConfigsLoaded'); + }.property('controller.isConfigsLoaded'), onPrimary: function () { - this.hide(); - primary(); + this._super(); + if (isReconfigure) { + self.applyConfigsCustomization(configs); + self.saveConfigsBatch(configs.groups, componentName, hostName); + if (primaryOnReconfigure) { + primaryOnReconfigure.call(self); + } + } else if (primary) { + primary(); + } } }); }, /** - * format message for operation of adding clients - * @param client - */ - formatClientsMessage: function (client) { - var displayName = Em.isNone(client.get('displayName')) ? '' : client.get('displayName'); - var subComponentNames = client.get('subComponentNames'); - if (subComponentNames && subComponentNames.length > 0) { - var dns = []; - subComponentNames.forEach(function (scn) { - dns.push(App.format.role(scn, false)); - }); - displayName += " (" + dns.join(", ") + ")"; - } - return displayName; - }, - - /** * Success callback for install host component request (sent in <code>addNewComponentSuccessCallback</code>) * @param {object} data * @param {object} opt @@ -807,7 +798,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow /** * get Oozie database config and set databaseType * @param {object} data - * @method onLoadHiveConfigs + * @method onLoadOozieConfigs */ onLoadOozieConfigs: function (data) { var configs = {}; @@ -931,7 +922,20 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow this.updateZkConfigs(configs, params.configs); - configs['storm-site']['nimbus.seeds'] = JSON.stringify(stormNimbusHosts).replace(/"/g, "'"); + var nimbusSeedsInit = configs['storm-site']['nimbus.seeds'], + nimbusSeedsRecommended = JSON.stringify(stormNimbusHosts).replace(/"/g, "'"); + configs['storm-site']['nimbus.seeds'] = nimbusSeedsRecommended; + if (params.configs && nimbusSeedsInit !== nimbusSeedsRecommended) { + var service = App.config.get('serviceByConfigTypeMap')['storm-site']; + params.configs.propertiesToChange.pushObject({ + propertyFileName: 'storm-site', + propertyName: 'nimbus.seeds', + serviceDisplayName: service && service.get('displayName'), + initialValue: nimbusSeedsInit, + recommendedValue: nimbusSeedsRecommended, + saveRecommended: true + }); + } var groups = [ { properties: { @@ -2540,7 +2544,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow allComponents.forEach(function (component, index) { var length = allComponents.get('length'); if (!deleteError) { - this._doDeleteHostComponent(component, function () { + this._doDeleteHostComponent(component.get('componentName'), function () { deleteError = self.get('_deletedHostComponentResult'); if (index == length - 1) { dfd.resolve(); @@ -2704,9 +2708,11 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow } }; if (clientsToAdd.length) { - var message = stringUtils.getFormattedStringFromArray(clientsToAdd.mapProperty('displayName')); - var isManualKerberos = App.get('router.mainAdminKerberosController.isManualKerberos'); - self.showAddComponentPopup(message, isManualKerberos, function () { + var message = stringUtils.getFormattedStringFromArray(clientsToAdd.mapProperty('displayName')), + componentObject = Em.Object.create({ + displayName: message + }); + self.showAddComponentPopup(componentObject, self.get('content.hostName'), function () { sendInstallCommand(); clientsToAdd.forEach(function (component) { self.installHostComponentCall(self.get('content.hostName'), component); http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index cc8102a..64a5e77 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2653,17 +2653,12 @@ Em.I18n.translations = { 'host.host.componentFilter.slave':'Slave Components', 'host.host.componentFilter.client':'Client Components', 'hosts.host.deleteComponent.popup.msg1':'Are you sure you want to delete {0}?', - 'hosts.host.deleteComponent.popup.deleteZooKeeperServer':'Deleting <i>ZooKeeper Server</i> may reconfigure such properties:<ul><li>zookeeper.connect</li><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li><li>hive.cluster.delegation.token.store.zookeeper.connectString</li><li>storm.zookeeper.servers</li><li>instance.zookeeper.host</li></ul>', - 'hosts.host.deleteComponent.popup.deleteRangerKMSServer': 'Deleting <i>Ranger KMS Server</i> may reconfigure such properties:<ul><li>hadoop.security.key.provider.path</li><li>dfs.encryption.key.provider.uri</li>', 'hosts.host.deleteComponent.popup.deleteJournalNodeMsg': 'You are about to open <i>Manage Journal Node Wizard</i>. Are you sure?', 'hosts.host.deleteComponent.popup.warning':'<b>WARNING!</b> Delete the last <i>{0}</i> component in the cluster?</br>Deleting the last component in the cluster could result in permanent loss of service data.', 'hosts.host.deleteComponent.popup.confirm':'Confirm Delete', 'hosts.host.installComponent.popup.confirm':'Confirm Install', 'hosts.host.installComponent.msg':'Are you sure you want to install {0}?', 'hosts.host.addComponent.msg':'Are you sure you want to add {0}?', - 'hosts.host.addComponent.ZOOKEEPER_SERVER':'Adding ZooKeeper Server may reconfigure such properties:<ul><li>zookeeper.connect</li><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li><li>hive.cluster.delegation.token.store.zookeeper.connectString</li><li>storm.zookeeper.servers</li><li>instance.zookeeper.host</li></ul>', - 'hosts.host.addComponent.NIMBUS': 'Adding Nimbus will reconfigure <b>nimbus.seeds</b>, <b>topology.min.replication.count</b>, <b>topology.max.replication.wait.time.sec</b> properties if they are defined.', - 'hosts.host.addComponent.RANGER_KMS_SERVER': 'Adding Ranger KMS Server may reconfigure such properties:<ul><li>hadoop.security.key.provider.path</li><li>dfs.encryption.key.provider.uri</li>', 'hosts.host.addComponent.deleteHostWithZooKeeper':'Deleting host with ZooKeeper Server may reconfigure such properties:<ul><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>', 'host.host.addComponent.popup.dependedComponents.body': '{0} requires {1} to be installed along with it on the same host. Please add them first and then try adding {0}', 'host.host.addComponent.popup.dependedComponents.header': 'Component dependencies', @@ -2689,8 +2684,6 @@ Em.I18n.translations = { 'hosts.host.hbase_regionserver.decommission.warning':'Last RegionServer can\'t be decommissioned', 'hosts.host.decommissioned':'Decommissioned', 'hosts.host.decommissioning':'Decommissioning', - 'hosts.host.addComponent.HIVE_METASTORE':'Adding <i>Hive Metastore</i> will reconfigure such properties:<ul><li>hive.metastore.uris</li><li>templeton.hive.properties</li></ul>', - 'hosts.host.addComponent.WEBHCAT_SERVER':'You are about to add <i>WebHCat Server</i>. Are you sure?', 'hosts.host.addComponent.JOURNALNODE': 'You are about to open <i>Manage Journal Node Wizard</i>. Are you sure?', 'hosts.host.deleteComponent.popup.deleteHiveMetastore':'Deleting <i>Hive Metastore</i> will reconfigure such properties:<ul><li>hive.metastore.uris</li><li>templeton.hive.properties</li></ul>', 'hosts.host.deleteComponent.popup.deleteWebHCatServer':'You are about to delete <i>WebHCat Server</i>. Are you sure?', http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/templates/main/host/details/addComponentPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/addComponentPopup.hbs b/ambari-web/app/templates/main/host/details/addComponentPopup.hbs deleted file mode 100644 index ff69b9e..0000000 --- a/ambari-web/app/templates/main/host/details/addComponentPopup.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{{! -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -}} - -{{addComponentMsg}}<br />{{{manualKerberosWarning}}} http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/templates/main/host/details/addComponentWithConfigsChanges.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/addComponentWithConfigsChanges.hbs b/ambari-web/app/templates/main/host/details/addComponentWithConfigsChanges.hbs deleted file mode 100644 index d62715d..0000000 --- a/ambari-web/app/templates/main/host/details/addComponentWithConfigsChanges.hbs +++ /dev/null @@ -1,27 +0,0 @@ -{{! -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -}} - -{{#if controller.isConfigsLoaded}} - {{view.commonMessage}} - {{#if view.propertiesToChange.length}} - {{view App.DependentConfigsListView isAfterRecommendation=false recommendationsBinding="view.propertiesToChange"}} - {{/if}} - {{{view.manualKerberosWarning}}} -{{else}} - {{view App.SpinnerView}} -{{/if}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/templates/main/host/details/addDeleteComponentPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/addDeleteComponentPopup.hbs b/ambari-web/app/templates/main/host/details/addDeleteComponentPopup.hbs new file mode 100644 index 0000000..713ad8c --- /dev/null +++ b/ambari-web/app/templates/main/host/details/addDeleteComponentPopup.hbs @@ -0,0 +1,40 @@ +{{! +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +}} + +{{#if view.lastComponent}} + <div class="alert alert-danger"> + <div class="row row-no-pad"> + <div class="col-md-1">{{view Ember.Checkbox checkedBinding="view.parentView.isChecked"}}</div> + <div class="col-md-11">{{{view.lastComponentError}}}</div> + </div> + </div> +{{/if}} +{{#if view.isReconfigure}} + {{#if controller.isConfigsLoaded}} + {{view.commonMessage}} + {{#if view.propertiesToChange.length}} + {{view App.DependentConfigsListView isAfterRecommendation=false recommendationsBinding="view.propertiesToChange"}} + {{/if}} + {{{view.manualKerberosWarning}}} + {{else}} + {{view App.SpinnerView}} + {{/if}} +{{else}} + <div>{{view.commonMessage}}</div> + <div>{{{view.manualKerberosWarning}}}</div> +{{/if}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs b/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs deleted file mode 100644 index 45cee97..0000000 --- a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs +++ /dev/null @@ -1,45 +0,0 @@ -{{! -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -}} - -<p>{{{deleteComponentMsg}}}</p> -{{#if lastComponent}} - <div class="alert alert-danger"> - <div class="row row-no-pad"> - <div class="col-md-1">{{view App.CheckboxView checkedBinding="isChecked"}}</div> - <div class="col-md-11">{{{lastComponentError}}}</div> - </div> - </div> -{{/if}} -{{#if isZkServer}} - <div class="alert alert-warning">{{{deleteZkServerMsg}}}</div> -{{/if}} -{{#if isHiveMetastore}} - <div class="alert alert-warning">{{{deleteHiveMetastoreMsg}}}</div> -{{/if}} -{{#if isWebHCatServer}} - <div class="alert alert-warning">{{{deleteWebHCatServerMsg}}}</div> -{{/if}} -{{#if isNimbus}} - <div class="alert alert-warning">{{{deleteNimbusMsg}}}</div> -{{/if}} -{{#if isRangerKMSServer}} - <div class="alert alert-warning">{{{deleteRangerKMSServereMsg}}}</div> -{{/if}} -{{#if isJournalNode}} - <div class="alert alert-warning">{{{deleteJournalNodeMsg}}}</div> -{{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/app/views/main/host/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js index 80c4890..89332de 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -215,11 +215,7 @@ App.MainHostSummaryView = Em.View.extend(App.TimeRangeMixin, { */ addableComponentObject: Em.Object.extend({ componentName: '', - subComponentNames: null, displayName: function () { - if (this.get('componentName') === 'CLIENTS') { - return this.t('common.clients'); - } return App.format.role(this.get('componentName'), false); }.property('componentName') }), http://git-wip-us.apache.org/repos/asf/ambari/blob/195f3ce1/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index 5dc13a9..4203644 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -500,125 +500,70 @@ describe('App.MainHostDetailsController', function () { }); describe('#addComponent()', function () { + var cases = [ + { + componentName: 'ZOOKEEPER_SERVER', + showAddComponentPopupCallCount: 1, + showConfirmationPopupCallCount: 0 + }, + { + componentName: 'RESOURCEMANAGER', + showAddComponentPopupCallCount: 1, + showConfirmationPopupCallCount: 0 + }, + { + componentName: 'JOURNALNODE', + showAddComponentPopupCallCount: 0, + showConfirmationPopupCallCount: 1 + }, + { + componentName: 'HIVE_CLIENT', + showAddComponentPopupCallCount: 1, + showConfirmationPopupCallCount: 0 + } + ]; beforeEach(function () { - sinon.stub(controller, "addClientComponent", Em.K); - sinon.stub(controller, "installHostComponentCall", Em.K); sinon.stub(controller, "checkComponentDependencies", Em.K); - sinon.stub(controller, "showAddComponentConfirmation", Em.K); + sinon.stub(controller, "showAddComponentPopup", Em.K); + sinon.stub(App, "showConfirmationPopup", Em.K); controller.set('content', { hostComponents: [Em.Object.create({ componentName: "HDFS_CLIENT" })] }); - controller.reopen({ - securityEnabled: false - }); }); afterEach(function () { - controller.addClientComponent.restore(); - controller.installHostComponentCall.restore(); controller.checkComponentDependencies.restore(); - controller.showAddComponentConfirmation.restore(); + controller.showAddComponentPopup.restore(); + App.showConfirmationPopup.restore(); }); - it('add ZOOKEEPER_SERVER', function () { - var event = { - context: Em.Object.create({ - componentName: 'ZOOKEEPER_SERVER' - }) - }; - controller.addComponent(event); - expect(controller.showAddComponentConfirmation.calledOnce).to.be.true; - }); - it('add WEBHCAT_SERVER', function () { - var event = { - context: Em.Object.create({ - componentName: 'WEBHCAT_SERVER' - }) - }; - controller.addComponent(event); - expect(controller.showAddComponentConfirmation.calledOnce).to.be.true; - }); - it('add slave component', function () { - var event = { - context: Em.Object.create({ - componentName: 'HIVE_CLIENT' - }) - }; - controller.set('securityEnabled', false); - controller.addComponent(event); - expect(controller.addClientComponent.calledWith(Em.Object.create({ - componentName: 'HIVE_CLIENT' - }))).to.be.true; - }); - }); + cases.forEach(function (testCase) { - describe('#formatClientsMessage()', function () { - var testCases = [ - { - title: 'subComponentNames is null', - client: Em.Object.create({ - subComponentNames: null, - displayName: 'CLIENTS' - }), - result: 'CLIENTS' - }, - { - title: 'subComponentNames is empty', - client: Em.Object.create({ - subComponentNames: [], - displayName: 'CLIENTS' - }), - result: 'CLIENTS' - }, - { - title: 'displayName is null', - client: Em.Object.create({ - subComponentNames: ['DATANODE'], - displayName: null - }), - result: ' (DataNode)' - }, - { - title: 'displayName is CLIENTS', - client: Em.Object.create({ - subComponentNames: ['DATANODE'], - displayName: 'CLIENTS' - }), - result: 'CLIENTS (DataNode)' - } - ]; - testCases.forEach(function (test) { - it(test.title, function () { - expect(controller.formatClientsMessage(test.client)).to.equal(test.result); - }); - }); - }); + describe('add ' + testCase.componentName, function () { - describe('#addClientComponent()', function () { + beforeEach(function () { + var event = { + context: Em.Object.create({ + componentName: testCase.componentName + }) + }; + controller.addComponent(event); + }); - var component = Em.Object.create({ - componentName: ' Comp1' - }); + it('controller.showAddComponentPopup', function () { + expect(controller.showAddComponentPopup.callCount).to.equal(testCase.showAddComponentPopupCallCount); + }); - beforeEach(function () { - sinon.spy(controller, 'showAddComponentPopup'); - sinon.stub(controller, 'installHostComponentCall', Em.K); - }); + it('App.showConfirmationPopup', function () { + expect(App.showConfirmationPopup.callCount).to.equal(testCase.showConfirmationPopupCallCount); + }); - afterEach(function () { - controller.showAddComponentPopup.restore(); - controller.installHostComponentCall.restore(); - }); + }); - it('any CLIENT component', function () { - controller.set('content.hostName', 'host1'); - var popup = controller.addClientComponent(component); - expect(controller.showAddComponentPopup.calledOnce).to.be.true; - popup.onPrimary(); - expect(controller.installHostComponentCall.calledWith('host1', component)).to.be.true; }); + }); describe("#loadOozieConfigs()", function() { @@ -824,7 +769,7 @@ describe('App.MainHostDetailsController', function () { var message = 'Comp1'; beforeEach(function () { - sinon.spy(App.ModalPopup, 'show'); + sinon.stub(App.ModalPopup, 'show'); }); afterEach(function () { @@ -832,9 +777,8 @@ describe('App.MainHostDetailsController', function () { }); it('should display add component confirmation', function () { - var popup = controller.showAddComponentPopup(message, false, Em.K); + controller.showAddComponentPopup(Em.Object.create()); expect(App.ModalPopup.show.calledOnce).to.be.true; - expect(popup.get('addComponentMsg')).to.eql(Em.I18n.t('hosts.host.addComponent.msg').format(message)); }); }); @@ -2538,8 +2482,8 @@ describe('App.MainHostDetailsController', function () { describe('#_doDeleteHostComponent()', function () { it('single component', function () { controller.set('content.hostName', 'host1'); - var component = Em.Object.create({componentName: 'COMP'}); - controller._doDeleteHostComponent(component); + var componentName = 'COMP'; + controller._doDeleteHostComponent(componentName); var args = testHelpers.findAjaxRequest('name', 'common.delete.host_component'); expect(args[0]).exists; expect(args[0].data).to.be.eql({ @@ -2560,77 +2504,28 @@ describe('App.MainHostDetailsController', function () { }); describe('#_doDeleteHostComponentSuccessCallback()', function () { + var data = { + componentName: 'COMPONENT', + hostName: 'h1' + }; + beforeEach(function () { sinon.stub(controller, 'removeHostComponentModel', Em.K); - sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) { - callback(); - }); - sinon.stub(controller, 'loadConfigs', Em.K); - sinon.stub(App.StackService, 'find').returns({ - compareCurrentVersion: function() {} - }); + controller.set('_deletedHostComponentResult', {}); + controller._doDeleteHostComponentSuccessCallback({}, {}, data); }); afterEach(function () { controller.removeHostComponentModel.restore(); - controller.isServiceMetricsLoaded.restore(); - controller.loadConfigs.restore(); - App.StackService.find.restore(); }); - it('ZOOKEEPER_SERVER component', function () { - var data = { - componentName: 'ZOOKEEPER_SERVER' - }; - controller._doDeleteHostComponentSuccessCallback({}, {}, data); - expect(controller.get('_deletedHostComponentResult')).to.be.null; - expect(controller.get('fromDeleteZkServer')).to.be.true; - expect(controller.loadConfigs.calledOnce).to.be.true; - }); - it('Not ZOOKEEPER_SERVER component', function () { - var data = { - componentName: 'COMP' - }; - controller.set('fromDeleteZkServer', false); - controller._doDeleteHostComponentSuccessCallback({}, {}, data); + it('should reset `_deletedHostComponentResult`', function () { expect(controller.get('_deletedHostComponentResult')).to.be.null; - expect(controller.get('fromDeleteZkServer')).to.be.false; }); + it('should call `removeHostComponentModel` with correct params', function () { - var data = { - componentName: 'COMPONENT', - hostName: 'h1' - }; - controller._doDeleteHostComponentSuccessCallback({}, {}, data); expect(controller.removeHostComponentModel.calledWith('COMPONENT', 'h1')).to.be.true; }); - it('HIVE_METASTORE component', function () { - var data = { - componentName: 'HIVE_METASTORE' - }; - controller._doDeleteHostComponentSuccessCallback({}, {}, data); - expect(controller.get('_deletedHostComponentResult')).to.be.null; - expect(controller.get('deleteHiveMetaStore')).to.be.true; - expect(controller.loadConfigs.calledWith('loadHiveConfigs')).to.be.true; - }); - it('NIMBUS component', function () { - var data = { - componentName: 'NIMBUS' - }; - controller._doDeleteHostComponentSuccessCallback({}, {}, data); - expect(controller.get('_deletedHostComponentResult')).to.be.null; - expect(controller.get('deleteNimbusHost')).to.be.true; - expect(controller.loadConfigs.calledWith('loadStormConfigs')).to.be.true; - }); - it('RANGER_KMS_SERVER component', function () { - var data = { - componentName: 'RANGER_KMS_SERVER' - }; - controller._doDeleteHostComponentSuccessCallback({}, {}, data); - expect(controller.get('_deletedHostComponentResult')).to.be.null; - expect(controller.get('deleteRangerKMSServer')).to.be.true; - expect(controller.loadConfigs.calledWith('loadRangerConfigs')).to.be.true; - }); }); describe('#upgradeComponentSuccessCallback()', function () { @@ -3086,9 +2981,7 @@ describe('App.MainHostDetailsController', function () { }); it('_doDeleteHostComponent is called with correct arguments', function () { - expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({ - componentName: 'COMP1' - }))).to.be.true; + expect(controller._doDeleteHostComponent.calledWith('COMP1')).to.be.true; }); it('fromDeleteHost is true', function () { expect(controller.get('fromDeleteHost')).to.be.true;
