You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/10/02 13:07:29 UTC
git commit: AMBARI-7608 Warning when deleting not last
host-component. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 0fdd4b348 -> a23758831
AMBARI-7608 Warning when deleting not last host-component. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a2375883
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a2375883
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a2375883
Branch: refs/heads/trunk
Commit: a23758831a3a3352d9d7a29e3a61af9a87963d34
Parents: 0fdd4b3
Author: atkach <at...@hortonworks.com>
Authored: Thu Oct 2 13:59:55 2014 +0300
Committer: atkach <at...@hortonworks.com>
Committed: Thu Oct 2 13:59:55 2014 +0300
----------------------------------------------------------------------
ambari-web/app/controllers/main/host/details.js | 20 +++++++-
.../test/controllers/main/host/details_test.js | 51 ++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a2375883/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 3fad22e..1f1bf8e 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -212,7 +212,7 @@ App.MainHostDetailsController = Em.Controller.extend({
var component = event.context;
var componentName = component.get('componentName');
var displayName = component.get('displayName');
- var isLastComponent = (App.HostComponent.find().filterProperty('componentName', componentName).get('length') === 1);
+ var isLastComponent = (this.getTotalComponent(component) === 1);
App.ModalPopup.show({
header: Em.I18n.t('popup.confirmation.commonHeader'),
primary: Em.I18n.t('hosts.host.deleteComponent.popup.confirm'),
@@ -253,6 +253,24 @@ App.MainHostDetailsController = Em.Controller.extend({
},
/**
+ * get total count of host-components
+ * @method getTotalComponent
+ * @param component
+ * @return {Number}
+ */
+ getTotalComponent: function (component) {
+ var count;
+ if (component.get('isSlave')) {
+ count = App.SlaveComponent.find(component.get('componentName')).get('totalCount');
+ } else if (component.get('isClient')) {
+ count = App.ClientComponent.find(component.get('componentName')).get('totalCount');
+ } else {
+ count = App.HostComponent.find().filterProperty('componentName', component.get('componentName')).get('length')
+ }
+ return count || 0;
+ },
+
+ /**
* Trigger to reset list of master/slaves components on the view
* @type {bool}
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/a2375883/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 9511c27..7c63460 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -1355,6 +1355,57 @@ describe('App.MainHostDetailsController', function () {
});
});
+ describe('#getTotalComponent()', function () {
+
+ beforeEach(function () {
+ sinon.stub(App.SlaveComponent, 'find', function() {
+ return Em.Object.create({
+ componentName: "SLAVE",
+ totalCount: 1
+ });
+ });
+ sinon.stub(App.ClientComponent, 'find', function() {
+ return Em.Object.create({
+ componentName: "CLIENT",
+ totalCount: 1
+ });
+ });
+ sinon.stub(App.HostComponent, 'find', function() {
+ return [Em.Object.create({
+ componentName: "MASTER",
+ totalCount: 1
+ })]
+ });
+ });
+ afterEach(function () {
+ App.SlaveComponent.find.restore();
+ App.ClientComponent.find.restore();
+ App.HostComponent.find.restore();
+ });
+
+ it('component is slave', function () {
+ expect(controller.getTotalComponent(Em.Object.create({
+ componentName: "SLAVE",
+ isSlave: true
+ }))).to.equal(1);
+ });
+ it('component is client', function () {
+ expect(controller.getTotalComponent(Em.Object.create({
+ componentName: "CLIENT",
+ isClient: true
+ }))).to.equal(1);
+ });
+ it('component is master', function () {
+ expect(controller.getTotalComponent(Em.Object.create({
+ componentName: "MASTER"
+ }))).to.equal(1);
+ });
+ it('unknown component', function () {
+ expect(controller.getTotalComponent(Em.Object.create({
+ componentName: "UNKNOWN"
+ }))).to.equal(0);
+ });
+ });
describe('#downloadClientConfigs()', function () {
beforeEach(function () {