Code coverage report for app/mixins/wizard/wizard_misc_property_checker.js

Statements: 36.67% (11 / 30)      Branches: 20% (3 / 15)      Functions: 25% (2 / 8)      Lines: 36.67% (11 / 30)      Ignored: none     

All files » app/mixins/wizard/ » wizard_misc_property_checker.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94    1                                     1   1   1 1 1 1   1   1       1   1                                                                                                              
'use strict';
 
;require.register("mixins/wizard/wizard_misc_property_checker", function (exports, require, module) {
  /**
   * 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');
 
  App.WizardMiscPropertyChecker = Em.Mixin.create({
    showConfirmationDialogIfShouldChangeProps: function showConfirmationDialogIfShouldChangeProps(changedProperty, stepConfigs, serviceId) {
      var serviceConfigModificationHandler = null;
      this.affectedProperties = [];
      try {
        serviceConfigModificationHandler = require('utils/configs/modification_handlers/' + serviceId.toLowerCase());
      } catch (e) {
        console.log("Unable to load modification handler for ", serviceId);
      }
      Iif (serviceConfigModificationHandler != null) {
        var securityEnabled = App.router.get('mainAdminKerberosController.securityEnabled');
        this.affectedProperties = serviceConfigModificationHandler.getDependentConfigChanges(changedProperty, this.get("controller.selectedServiceNames"), stepConfigs, securityEnabled);
      }
      changedProperty.set("editDone", false); // Turn off flag
 
      Iif (this.affectedProperties.length > 0 && !this.get("controller.miscModalVisible")) {
        this.newAffectedProperties = this.affectedProperties;
        var self = this;
        return App.ModalPopup.show({
          classNames: ['modal-690px-width'],
          modalDialogClasses: ['modal-lg'],
          showCloseButton: false,
          primary: Em.I18n.t('common.apply'),
          secondary: serviceId == 'MISC' ? Em.I18n.t('common.ignore') : null,
          third: Em.I18n.t('common.cancel'),
          secondaryClass: 'btn-warning',
          header: "Warning: you must also change these Service properties",
          onPrimary: function onPrimary() {
            self.get("newAffectedProperties").forEach(function (item) {
              if (item.isNewProperty) {
                self.createProperty({
                  name: item.propertyName,
                  displayName: item.propertyDisplayName,
                  value: item.newValue,
                  categoryName: item.categoryName,
                  serviceName: item.serviceName,
                  filename: item.filename
                });
              } else {
                self.get("controller.stepConfigs").findProperty("serviceName", item.serviceName).get("configs").find(function (config) {
                  return item.propertyName == config.get('name') && (item.filename == null || item.filename == config.get('filename'));
                }).set("value", item.newValue);
              }
            });
            self.get("controller").set("miscModalVisible", false);
            this.hide();
          },
          onSecondary: function onSecondary() {
            self.get("controller").set("miscModalVisible", false);
            this.hide();
          },
          onThird: function onThird() {
            var affected = self.get("newAffectedProperties").objectAt(0),
                changedProperty = self.get("controller.stepConfigs").findProperty("serviceName", affected.sourceServiceName).get("configs").findProperty("name", affected.changedPropertyName);
            changedProperty.set('value', changedProperty.get('savedValue') || changedProperty.get('initialValue'));
            self.get("controller").set("miscModalVisible", false);
            this.hide();
          },
          bodyClass: Em.View.extend({
            templateName: require('templates/common/configs/propertyDependence'),
            controller: this,
            propertyChange: self.get("newAffectedProperties"),
            didInsertElement: function didInsertElement() {
              self.get("controller").set("miscModalVisible", true);
            }
          })
        });
      }
    }
  });
});