Pārlūkot izejas kodu

AMBARI-19814. 'num_llap_nodes' should show up as non-editable property when non-ambari managed queue is selected (onechiporenko)

Oleg Nechiporenko 8 gadi atpakaļ
vecāks
revīzija
0f4775bf6a

+ 1 - 0
ambari-web/app/mixins.js

@@ -52,6 +52,7 @@ require('mixins/wizard/addSecurityConfigs');
 require('mixins/wizard/wizard_menu_view');
 require('mixins/wizard/assign_master_components');
 require('mixins/wizard/wizardHostsLoading');
+require('mixins/common/configs/widgets/unique/num_llap_nodes');
 require('mixins/common/configs/config_recommendations');
 require('mixins/common/configs/config_recommendation_parser');
 require('mixins/common/configs/config_with_override_recommendation_parser');

+ 70 - 0
ambari-web/app/mixins/common/configs/widgets/unique/num_llap_nodes.js

@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+/**
+ * Slider for `num_llap_nodes` should have unique widget
+ *
+ * @type {Em.Mixin}
+ */
+App.NumLlapNodesWidgetMixin = Em.Mixin.create({
+
+  /**
+   * @type {boolean}
+   */
+  readOnly: Em.computed.alias('config.stackConfigProperty.valueAttributes.read_only'),
+
+  /**
+   * @type {boolean}
+   */
+  doNotShowWidget: function () {
+    if (this.get('readOnly')) {
+      return false;
+    }
+    return this.get('isPropertyUndefined') || this.get('config.showAsTextBox');
+  }.property('isPropertyUndefined', 'config.showAsTextBox', 'readOnly'),
+
+  handleReadOnlyAttribute: function () {
+    var readOnly = this.get('readOnly');
+    this.set('disabled', readOnly);
+    this.set('supportSwitchToTextBox', !readOnly);
+    if (readOnly) {
+      this.toggleSlider('disable');
+    }
+  }.observes('readOnly'),
+
+  toggleWidgetView: function() {
+    this._super();
+    var action = !this.get('config.showAsTextBox') && this.get('readOnly') ? 'disable' : 'enable';
+    this.toggleSlider(action);
+  },
+
+  toggleWidgetState: function () {
+    this.set('disabled', !this.get('config.isEditable'));
+  }.observes('config.isEditable'),
+
+  toggleSlider: function (action) {
+    var self = this;
+    Em.run.next(function () {
+      self.get('slider')[action]();
+    });
+  }
+
+});

+ 2 - 0
ambari-web/app/templates/common/configs/widgets/controls.hbs

@@ -33,6 +33,7 @@
   {{/unless}}
 {{/if}}
 {{#if view.canEdit}}
+  {{#unless view.readOnly}}
   <div {{bindAttr class=":widget-config-controls view.referToSelectedGroup::clear-min-height"}}>
     <div {{bindAttr class=":widget-col :left view.config.isNotDefaultValue::not-show"}}>
       <a href="#"
@@ -98,6 +99,7 @@
       {{/if}}
     </div>
   </div>
+  {{/unless}}
 {{/if}}
 
 {{#if controller.selectedConfigGroup.isDefault}}

+ 20 - 3
ambari-web/app/views/common/configs/service_config_layout_tab_view.js

@@ -67,6 +67,10 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
     'test-db-connection': App.TestDbConnectionWidgetView
   },
 
+  configNameWidgetMixinMap: {
+    num_llap_nodes: App.NumLlapNodesWidgetMixin
+  },
+
   /**
    * Prepare configs for render
    * <code>subsection.configs</code> is an array of App.StackConfigProperty, but not App.ConfigProperty,
@@ -108,9 +112,9 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
       if (!configProperty) return;
 
       containerObject.get('configs').pushObject(configProperty);
-      var configWidgetType = Em.get(config, 'widgetType');
-      var widget = self.get('widgetTypeMap')[configWidgetType];
-      Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' + configWidgetType, widget);
+
+      var widget = self.getWidgetView(config);
+      Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' +  Em.get(config, 'widgetType'), widget);
 
       var additionalProperties = {
         widget: widget,
@@ -160,6 +164,19 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
     });
   },
 
+  /**
+   *
+   * @param {object} config
+   * @returns {Em.View}
+   */
+  getWidgetView: function (config) {
+    var configWidgetType = Em.get(config, 'widgetType');
+    var name = Em.get(config, 'name');
+    var mixin = this.get('configNameWidgetMixinMap')[name];
+    var viewClass = this.get('widgetTypeMap')[configWidgetType];
+    return Em.isNone(mixin) ? viewClass : viewClass.extend(mixin);
+  },
+
   /**
    * changes active subsection tab
    * @param event