ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-7831. Slider View: metrics and metric ui links should be at the and of the list. (Denys Buzhor via akovalenko)
Date Fri, 17 Oct 2014 16:30:58 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 8bf2a3e2a -> eb81775aa


AMBARI-7831. Slider View: metrics and metric ui links should be at the and of the list. (Denys
Buzhor via akovalenko)


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

Branch: refs/heads/branch-1.7.0
Commit: eb81775aa98d4b59c132603a8f311e0564bd7cd6
Parents: 8bf2a3e
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Fri Oct 17 16:36:18 2014 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Fri Oct 17 19:30:22 2014 +0300

----------------------------------------------------------------------
 .../ui/app/controllers/slider_app_controller.js | 19 +++++++++++++
 .../resources/ui/app/templates/slider_app.hbs   |  2 +-
 .../controllers/slider_app_controller_test.js   | 29 ++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eb81775a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
index 622c9f9..15792ef 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
@@ -42,6 +42,25 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler,
{
   }.property('model.quickLinks.content.content.length'),
 
   /**
+   * Quick links in custom order.
+   *
+   * @type {Array}
+   **/
+  quickLinksOrdered: function() {
+    var copy = this.store.all('quick-link').slice(0);
+    var toTail = ['Metrics UI', 'Metrics API'];
+
+    if (this.get('weHaveQuicklinks')) {
+      toTail.forEach(function(labelName) {
+        if (copy.findBy('label', labelName)) {
+          copy = copy.concat(copy.splice(copy.indexOf(copy.findBy('label', labelName)), 1));
+        }
+      });
+    }
+    return copy;
+  }.property('model.quickLinks.content.content.length', 'weHaveQuicklinks'),
+
+  /**
    * List of all possible actions for slider app
    * @type {Em.Object}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb81775a/contrib/views/slider/src/main/resources/ui/app/templates/slider_app.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/slider_app.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/slider_app.hbs
index 7b81b20..79534a0 100644
--- a/contrib/views/slider/src/main/resources/ui/app/templates/slider_app.hbs
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/slider_app.hbs
@@ -53,7 +53,7 @@
         <li class="dropdown">
           <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{t common.quickLinks}}<b
class="caret"></b></a>
           <ul class="dropdown-menu">
-            {{#each quickLink in model.quickLinks}}
+            {{#each quickLink in controller.quickLinksOrdered}}
               <li><a {{bind-attr href="quickLink.url"}} target="_blank">{{quickLink.label}}</a></li>
             {{/each}}
           </ul>

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb81775a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
index 1db72d6..c022d24 100644
--- a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
+++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
@@ -62,3 +62,32 @@ test('availableActions', function () {
   ok(controller.get('availableActions').mapBy('action').contains('thaw'), 'actions for FROZEN
(2)');
 
 });
+
+test('quickLinksOrdered', function() {
+  expect(2);
+
+  var controller = this.subject({
+    store: Em.Object.create({
+      all: function(model) {
+        return {
+          'quick-link': [
+            Em.Object.create({ label: 'org.apache.slider.thrift'}),
+            Em.Object.create({ label: 'Metrics API'}),
+            Em.Object.create({ label: 'org.apache.slider.hbase'}),
+            Em.Object.create({ label: 'Metrics UI'}),
+            Em.Object.create({ label: 'UI'}),
+            Em.Object.create({ label: 'Some Label'})
+          ]
+        }[model];
+      }
+    }),
+    weHaveQuicklinks: true
+  });
+
+  Em.run(function() {
+    controller.get('quickLinksOrdered');
+  });
+
+  equal(controller.get('quickLinksOrdered').objectAt(4).get('label'), 'Metrics UI', 'Metrics
UI link should be before Metrics API');
+  equal(controller.get('quickLinksOrdered').objectAt(5).get('label'), 'Metrics API', 'Metrics
API link should be last');
+});


Mime
View raw message