浏览代码

AMBARI-8731 Navigating to/from hosts causes increasing number of Versions tab. (ababiichuk)

aBabiichuk 10 年之前
父节点
当前提交
870030a44c
共有 1 个文件被更改,包括 10 次插入18 次删除
  1. 10 18
      ambari-web/app/views/main/host/menu.js

+ 10 - 18
ambari-web/app/views/main/host/menu.js

@@ -40,24 +40,17 @@ App.MainHostMenuView = Em.CollectionView.extend({
       routing: 'alerts',
       badgeText: '0',
       badgeClasses: 'label'
+    }),
+    Em.Object.create({
+      name: 'versions',
+      label: Em.I18n.t('hosts.host.menu.stackVersions'),
+      routing: 'stackVersions',
+      hidden: function() {
+        return !App.get('supports.stackUpgrade')
+      }.property('App.get.supports.stackUpgrade')
     })
   ],
 
-  /**
-   * Add conditional menu options
-   */
-  setConditionalOptions: function () {
-    if (App.get('supports.stackUpgrade')) {
-      this.get('content').push(
-          Em.Object.create({
-            name: 'versions',
-            label: Em.I18n.t('hosts.host.menu.stackVersions'),
-            routing: 'stackVersions'
-          })
-      );
-    }
-  },
-
   /**
    * Update Alerts menu option counter text and class
    */
@@ -79,7 +72,6 @@ App.MainHostMenuView = Em.CollectionView.extend({
 
   init: function () {
     this._super();
-    this.setConditionalOptions();
     this.updateAlertCounter();
     this.activateView();
   },
@@ -100,10 +92,10 @@ App.MainHostMenuView = Em.CollectionView.extend({
   itemViewClass: Em.View.extend({
     classNameBindings: ["active"],
     active: "",
-    template: Ember.Handlebars.compile('<a {{action hostNavigate view.content.routing }} href="#"> {{unbound view.content.label}} ' +
+    template: Ember.Handlebars.compile('{{#unless view.content.hidden}}<a {{action hostNavigate view.content.routing }} href="#"> {{unbound view.content.label}} ' +
     '{{#if view.content.badgeText}} ' +
     '<span {{bindAttr class="view.content.badgeClasses"}}> ' +
     '{{view.content.badgeText}}' +
-    '</span>  {{/if}}</a>')
+    '</span>  {{/if}}</a>{{/unless}}')
   })
 });