Repository: ambari Updated Branches: refs/heads/trunk 025adab08 -> c0dd81615
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/c0dd8161 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c0dd8161 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c0dd8161 Branch: refs/heads/trunk Commit: c0dd81615ea35b868d425905aa63744d3847dc77 Parents: 025adab Author: Aleksandr Kovalenko <[email protected]> Authored: Fri Oct 17 17:29:35 2014 +0300 Committer: Aleksandr Kovalenko <[email protected]> Committed: Fri Oct 17 19:20:33 2014 +0300 ---------------------------------------------------------------------- .../ui/app/controllers/slider_app_controller.js | 19 +++++++++++++ .../resources/ui/app/templates/slider_app.hbs | 4 +-- .../controllers/slider_app_controller_test.js | 29 ++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c0dd8161/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/c0dd8161/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 54b94f5..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> @@ -67,4 +67,4 @@ {{outlet}} </div> -</div> \ No newline at end of file +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/c0dd8161/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'); +});
