ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [31/50] [abbrv] ambari git commit: AMBARI-13257 Assign unique id/class to database selection radio buttons/pulldowns. (ababiichuk)
Date Wed, 30 Sep 2015 14:45:51 GMT
AMBARI-13257 Assign unique id/class to database selection radio buttons/pulldowns. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f67543c4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f67543c4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f67543c4

Branch: refs/heads/branch-dev-patch-upgrade
Commit: f67543c406be7d014c3c35c1c572f6ff501241be
Parents: 291b7cb
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Sep 28 15:02:54 2015 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Mon Sep 28 15:02:54 2015 +0300

----------------------------------------------------------------------
 .../controls_service_config_radio_buttons.hbs   |  2 +-
 ambari-web/app/views/common/controls_view.js    | 20 ++++-
 .../test/views/common/controls_view_test.js     | 77 +++++++++++++++-----
 3 files changed, 80 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f67543c4/ambari-web/app/templates/wizard/controls_service_config_radio_buttons.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/controls_service_config_radio_buttons.hbs b/ambari-web/app/templates/wizard/controls_service_config_radio_buttons.hbs
index c9862c6..2187155 100644
--- a/ambari-web/app/templates/wizard/controls_service_config_radio_buttons.hbs
+++ b/ambari-web/app/templates/wizard/controls_service_config_radio_buttons.hbs
@@ -18,7 +18,7 @@
 
 {{#each option in view.options}}
   {{#unless option.hidden}}
-    <label class="radio">
+    <label {{bindAttr class="option.className :radio"}}>
       {{#view App.ServiceConfigRadioButton nameBinding = "view.name" valueBinding = "option.displayName"}}{{/view}}
       {{option.displayName}} &nbsp;
     </label>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f67543c4/ambari-web/app/views/common/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js
index 17eb6bd..523026c 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -698,7 +698,25 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
     }
   }.observes('serviceConfig.value'),
 
-  optionsBinding: 'serviceConfig.options'
+  options: function () {
+    return this.get('serviceConfig.options').map(function (option) {
+      var dbTypePattern = /mysql|postgres|oracle|derby|mssql|sql\s?a/i,
+        className = '',
+        displayName = Em.get(option, 'displayName'),
+        dbTypeMatch = displayName.match(dbTypePattern);
+      if (dbTypeMatch) {
+        var dbSourcePattern = /new/i,
+          newDbMatch = displayName.match(dbSourcePattern);
+        if (newDbMatch) {
+          className += 'new-';
+        }
+        className += dbTypeMatch[0].replace(' ', '').toLowerCase();
+      }
+      return className ? Em.Object.create(option, {
+        className: className
+      }) : option;
+    });
+  }.property('serviceConfig.options')
 });
 
 App.ServiceConfigRadioButton = Ember.Checkbox.extend({

http://git-wip-us.apache.org/repos/asf/ambari/blob/f67543c4/ambari-web/test/views/common/controls_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js
index ea20450..fdf3739 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -22,8 +22,13 @@ var validator = require('utils/validator');
 
 describe('App.ServiceConfigRadioButtons', function () {
 
+  var view;
+
+  beforeEach(function () {
+    view = App.ServiceConfigRadioButtons.create();
+  });
+
   describe('#setConnectionUrl', function () {
-    var view = App.ServiceConfigRadioButtons.create();
     beforeEach(function () {
       sinon.stub(view, 'getPropertyByType', function (name) {
         return App.ServiceConfigProperty.create({'name': name});
@@ -44,21 +49,21 @@ describe('App.ServiceConfigRadioButtons', function () {
   });
 
   describe('#setRequiredProperties', function () {
-    var view = App.ServiceConfigRadioButtons.create({
-      serviceConfig: Em.Object.create(),
-      categoryConfigsAll: [
-        App.ServiceConfigProperty.create({
-          name: 'p1',
-          value: 'v1'
-        }),
-        App.ServiceConfigProperty.create({
-          name: 'p2',
-          value: 'v2'
-        })
-      ]
-    });
 
     beforeEach(function () {
+      view.reopen({
+        serviceConfig: Em.Object.create(),
+        categoryConfigsAll: [
+          App.ServiceConfigProperty.create({
+            name: 'p1',
+            value: 'v1'
+          }),
+          App.ServiceConfigProperty.create({
+            name: 'p2',
+            value: 'v2'
+          })
+        ]
+      });
       sinon.stub(view, 'getPropertyByType', function (name) {
         return view.get('categoryConfigsAll').findProperty('name', name);
       });
@@ -81,8 +86,7 @@ describe('App.ServiceConfigRadioButtons', function () {
 
   describe('#handleDBConnectionProperty', function () {
 
-    var view,
-      cases = [
+    var cases = [
         {
           dbType: 'mysql',
           driver: 'mysql-connector-java.jar',
@@ -273,7 +277,7 @@ describe('App.ServiceConfigRadioButtons', function () {
     cases.forEach(function (item) {
       it(item.title, function () {
         sinon.stub(App, 'get').withArgs('currentStackName').returns('HDP').withArgs('currentStackVersion').returns(item.currentStackVersion);
-        view = App.ServiceConfigRadioButtons.create({controller: item.controller});
+        view.reopen({controller: item.controller});
         sinon.stub(view, 'sendRequestRorDependentConfigs', Em.K);
         view.setProperties({
           categoryConfigsAll: item.controller.get('selectedService.configs'),
@@ -290,6 +294,45 @@ describe('App.ServiceConfigRadioButtons', function () {
     });
 
   });
+
+  describe('#options', function () {
+
+    var options = [
+        {
+          displayName: 'MySQL'
+        },
+        {
+          displayName: 'New PostgreSQL Database'
+        },
+        {
+          displayName: 'existing postgres db'
+        },
+        {
+          displayName: 'sqla database: existing'
+        },
+        {
+          displayName: 'SQL Anywhere database (New)'
+        },
+        {
+          displayName: 'displayName'
+        }
+      ],
+      classNames = ['mysql', 'new-postgres', 'postgres', 'sqla', 'new-sqla', undefined];
+
+    beforeEach(function () {
+      view.reopen({
+        serviceConfig: Em.Object.create({
+          options: options
+        })
+      });
+    });
+
+    it('should set class names for options', function () {
+      expect(view.get('options').mapProperty('displayName')).to.eql(options.mapProperty('displayName'));
+      expect(view.get('options').mapProperty('className')).to.eql(classNames);
+    });
+
+  });
 });
 
 describe('App.ServiceConfigRadioButton', function () {


Mime
View raw message