Repository: ambari Updated Branches: refs/heads/trunk 48864260d -> 9c7e76151
AMBARI-17358. After switching to external database in hive, user should be allowed to delete mysql server (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9c7e7615 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9c7e7615 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9c7e7615 Branch: refs/heads/trunk Commit: 9c7e7615128652b5abb8216946007d59f9a2dced Parents: 4886426 Author: Alex Antonenko <[email protected]> Authored: Fri Jul 1 18:36:00 2016 +0300 Committer: Alex Antonenko <[email protected]> Committed: Fri Jul 1 19:45:12 2016 +0300 ---------------------------------------------------------------------- ambari-web/app/models/stack_service_component.js | 2 +- ambari-web/app/routes/main.js | 12 ++++++++++++ .../main/host/details/host_component_view.js | 8 ++++++++ .../test/models/stack_service_component_test.js | 3 ++- .../host/details/host_component_view_test.js | 19 ++++++++++++++++++- 5 files changed, 41 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7e7615/ambari-web/app/models/stack_service_component.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/stack_service_component.js b/ambari-web/app/models/stack_service_component.js index a350f15..17c2aa1 100644 --- a/ambari-web/app/models/stack_service_component.js +++ b/ambari-web/app/models/stack_service_component.js @@ -103,7 +103,7 @@ App.StackServiceComponent = DS.Model.extend({ /** @property {Boolean} isDeletable - component supports delete action **/ isDeletable: function() { var ignored = []; - return this.get('isAddableToHost') && !ignored.contains(this.get('componentName')); + return (this.get('isAddableToHost') && !ignored.contains(this.get('componentName'))) || (this.get('componentName') == 'MYSQL_SERVER'); }.property('componentName'), /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/ http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7e7615/ambari-web/app/routes/main.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js index ae16e27..8d33a68 100644 --- a/ambari-web/app/routes/main.js +++ b/ambari-web/app/routes/main.js @@ -216,9 +216,21 @@ module.exports = Em.Route.extend(App.RouterRedirections, { connectOutlets: function (router, context) { router.get('mainController').dataLoading().done(function() { var controller = router.get('mainHostDetailsController'); + var tags =[{ + siteName: 'hive-env' + }]; if ( App.Service.find().mapProperty('serviceName').contains('OOZIE')) { controller.loadConfigs('loadOozieConfigs'); controller.isOozieConfigLoaded.always(function () { + if(App.Service.find().mapProperty('serviceName').contains('HIVE')){ + App.router.get('configurationController').getConfigsByTags(tags).always(function () { + controller.connectOutlet('mainHostSummary'); + }); + } else + controller.connectOutlet('mainHostSummary'); + }); + } else if(App.Service.find().mapProperty('serviceName').contains('HIVE')) { + App.router.get('configurationController').getConfigsByTags(tags).always(function () { controller.connectOutlet('mainHostSummary'); }); } else { http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7e7615/ambari-web/app/views/main/host/details/host_component_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/details/host_component_view.js b/ambari-web/app/views/main/host/details/host_component_view.js index 910c71f..16071eb 100644 --- a/ambari-web/app/views/main/host/details/host_component_view.js +++ b/ambari-web/app/views/main/host/details/host_component_view.js @@ -192,6 +192,14 @@ App.HostComponentView = Em.View.extend({ isDeleteComponentDisabled: function () { var stackComponentCount = App.StackServiceComponent.find(this.get('hostComponent.componentName')).get('minToInstall'); var installedCount = App.HostComponent.getCount(this.get('hostComponent.componentName'), 'totalCount'); + if(this.get('hostComponent.componentName') == 'MYSQL_SERVER' && this.get('hostComponent.serviceDisplayName') == 'Hive') { + var db_type=App.db.getConfigs().findProperty('type','hive-env').properties['hive_database']; + var status=[App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus')); + if(db_type.indexOf('Existing') > -1 && status) + return false; + else + return true; + } return (installedCount <= stackComponentCount) || ![App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus')); }.property('workStatus'), http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7e7615/ambari-web/test/models/stack_service_component_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/stack_service_component_test.js b/ambari-web/test/models/stack_service_component_test.js index 7e971ce..6182c0a 100644 --- a/ambari-web/test/models/stack_service_component_test.js +++ b/ambari-web/test/models/stack_service_component_test.js @@ -292,7 +292,8 @@ var componentPropertiesValidationTests = [ { componentName: 'MYSQL_SERVER', expected: { - isShownOnInstallerAssignMasterPage: false + isShownOnInstallerAssignMasterPage: false, + isDeletable: true } } ]; http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7e7615/ambari-web/test/views/main/host/details/host_component_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/host/details/host_component_view_test.js b/ambari-web/test/views/main/host/details/host_component_view_test.js index 648f0f6..1a5936e 100644 --- a/ambari-web/test/views/main/host/details/host_component_view_test.js +++ b/ambari-web/test/views/main/host/details/host_component_view_test.js @@ -107,7 +107,15 @@ describe('App.HostComponentView', function() { App.TestAliases.testAsComputedEqual(getView(), 'isActive', 'content.passiveState', 'OFF'); describe('#isDeleteComponentDisabled', function() { - + var configs=[ + { + properties: { + 'hive_database': 'Existing MYSQL Database' + }, + tag: 'version2', + type: 'hive-env' + } + ]; beforeEach(function() { this.mock = sinon.stub(App.StackServiceComponent, 'find'); sinon.stub(App.HostComponent, 'getCount').returns(1); @@ -137,6 +145,15 @@ describe('App.HostComponentView', function() { hostComponentView.propertyDidChange('isDeleteComponentDisabled'); expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.true; }); + + it('delete is enabled because mysql server is stopped and hive is using external database', function() { + App.db.setConfigs(configs); + this.mock.returns(Em.Object.create({minToInstall: 0})); + hostComponentView.get('hostComponent').set('componentName', 'MYSQL_SERVER'); + hostComponentView.get('hostComponent').set('workStatus', 'STOPPED'); + hostComponentView.propertyDidChange('isDeleteComponentDisabled'); + expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.true; + }); }); describe('#componentTextStatus', function() {
