Browse Source

AMBARI-13465. Customize Services opens the "Advanced" tab by default

Alex Antonenko 9 years ago
parent
commit
823c3b988d

+ 5 - 0
ambari-web/app/models/configs/theme/tab.js

@@ -30,6 +30,11 @@ App.Tab = DS.Model.extend({
   isAdvancedHidden: DS.attr('boolean', {defaultValue: false}),
   isAdvancedHidden: DS.attr('boolean', {defaultValue: false}),
   isRendered: DS.attr('boolean', {defaultValue: false}),
   isRendered: DS.attr('boolean', {defaultValue: false}),
 
 
+  /**
+   * Determines if all <code>configs</code> were attached to tab.
+   */
+  isConfigsPrepared: DS.attr('boolean', {defaultValue: false}),
+
   /**
   /**
    * Number of the errors in all sections in the current tab
    * Number of the errors in all sections in the current tab
    * @type {number}
    * @type {number}

+ 2 - 0
ambari-web/app/views/common/configs/service_config_layout_tab_view.js

@@ -172,11 +172,13 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
 
 
   didInsertElement: function () {
   didInsertElement: function () {
     this.set('dataIsReady', false);
     this.set('dataIsReady', false);
+    this.set('content.isConfigsPrepared', false);
     this._super();
     this._super();
     this.prepareConfigProperties();
     this.prepareConfigProperties();
     if (this.get('controller.isCompareMode')) {
     if (this.get('controller.isCompareMode')) {
       this.get('parentView').filterEnhancedConfigs();
       this.get('parentView').filterEnhancedConfigs();
     }
     }
+    this.set('content.isConfigsPrepared', true);
     this.set('dataIsReady', true);
     this.set('dataIsReady', true);
   }
   }
 
 

+ 18 - 1
ambari-web/app/views/common/configs/service_config_view.js

@@ -30,6 +30,12 @@ App.ServiceConfigView = Em.View.extend({
    */
    */
   filter: '',
   filter: '',
 
 
+  /**
+   * Determines that active tab is set during view initialize.
+   * @type {boolean}
+   */
+  initalActiveTabIsSet: false,
+
   /**
   /**
    * Bound from parent view in the template
    * Bound from parent view in the template
    * @type {object[]}
    * @type {object[]}
@@ -180,10 +186,21 @@ App.ServiceConfigView = Em.View.extend({
       advancedTab.set('isRendered', false);
       advancedTab.set('isRendered', false);
     }
     }
     this.processTabs(tabs);
     this.processTabs(tabs);
-    this.pickActiveTab(tabs);
     return tabs;
     return tabs;
   }.property('controller.selectedServiceNameTrigger'),
   }.property('controller.selectedServiceNameTrigger'),
 
 
+  /**
+   * Set active tab when view attached and configs are linked to tabs.
+   */
+  initialActiveTabObserver: function() {
+    var tabs = this.get('tabs').filterProperty('isAdvanced', false);
+    if (tabs.everyProperty('isConfigsPrepared', true) && !this.get('initalActiveTabIsSet')) {
+      this.get('tabs').setEach('isActive', false);
+      this.pickActiveTab(this.get('tabs'));
+      this.set('tabsWereSet', true);
+    }
+  }.observes('tabs.@each.isConfigsPrepared'),
+
   /**
   /**
    * Pick the first non hidden tab and make it active when there is no active tab
    * Pick the first non hidden tab and make it active when there is no active tab
    * @method pickActiveTab
    * @method pickActiveTab