<commit_before>import { get, set } from '@ember/object';
import { equal } from '@ember/object/computed';
import { next } from '@ember/runloop';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import NewOrEdit from 'shared/mixins/new-or-edit';
import { debouncedObserver } from 'ui/utils/debounce';
import C from 'ui/utils/constants';
import ChildHook from 'shared/mixins/child-hook';
import { flattenLabelArrays } from 'shared/mixins/manage-labels';
import layout from './template';

export default Component.extend(NewOrEdit, ChildHook, {
  layout,
  clusterStore: service(),
  intl: service(),
  prefs: service(),
  settings: service(),

  tagName: 'form',

  isUpgrade: false,
  service: null,
  launchConfig: null,
  launchConfigIndex: null,

  namespace: null,
  scale: 1,
  scaleMode: null,

  serviceLinksArray: null,
  isRequestedHost: null,
  upgradeOptions: null,
  separateLivenessCheck: false,

  // Errors from components
  commandErrors: null,
  volumeErrors: null,
  networkingErrors: null,
  secretsErrors: null,
  readyCheckErrors: null,
  liveCheckErrors: null,
  schedulingErrors: null,
  securityErrors: null,
  scaleErrors: null,
  imageErrors: null,
  portErrors: null,
  namespaceErrors: null,
  labelErrors: null,
  annotationErrors: null,

  actions: {
    setImage(uuid) {
      set(this, 'launchConfig.image', uuid);
    },

    setLabels(section, labels) {
      set(this, section + 'Labels', labels);
    },

    setRequestedHostId(hostId) {
      set(this, 'launchConfig.requestedHostId', hostId);
    },

    setUpgrade(upgrade) {
      set(this, 'upgradeOptions', upgrade);
    },

    done() {
      this.sendAction('done');
    },

    cancel() {
      this.sendAction('cancel');
    },

    toggleSeparateLivenessCheck() {
      set(this, 'separateLivenessCheck', !get(this, 'separateLivenessCheck'));
    },

    removeSidekick(idx) {
      var ary = get(this, 'primaryService.secondaryLaunchConfigs');
      ary.removeAt(idx);
    },
  },

  init() {
    window.nec = this;
    this._super(...arguments);

    if (!get(this, 'launchConfig.environmentFrom')) {
      set(this, 'launchConfig.environmentFrom', []);
    }

    const service = get(this, 'service');

    if (!get(this, 'isSidekick') &&
      service && !get(service, 'scheduling')) {
      set(service, 'scheduling', {
        node: {}
      });
    }

    if (!get(this, 'isSidekick')) {
      this.setProperties({
        name: get(this, 'service.name'),
        description: get(this, 'service.description'),
        scale: get(this, 'service.scale'),
        scheduling: get(this, 'service.scheduling'),
      });
    } else {
      this.setProperties({<commit_msg>bug fixes<commit_after>import { get, set } from '@ember/object';
import { equal } from '@ember/object/computed';
import { next } from '@ember/runloop';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import NewOrEdit from 'shared/mixins/new-or-edit';
import { debouncedObserver } from 'ui/utils/debounce';
import C from 'ui/utils/constants';
import ChildHook from 'shared/mixins/child-hook';
import { flattenLabelArrays } from 'shared/mixins/manage-labels';
import layout from './template';

export default Component.extend(NewOrEdit, ChildHook, {
  layout,
  clusterStore: service(),
  intl: service(),
  prefs: service(),
  settings: service(),

  tagName: 'form',

  isUpgrade: false,
  service: null,
  launchConfig: null,
  launchConfigIndex: null,

  namespace: null,
  scale: 1,
  scaleMode: null,

  serviceLinksArray: null,
  isRequestedHost: null,
  upgradeOptions: null,
  separateLivenessCheck: false,

  // Errors from components
  commandErrors: null,
  volumeErrors: null,
  networkingErrors: null,
  secretsErrors: null,
  readyCheckErrors: null,
  liveCheckErrors: null,
  schedulingErrors: null,
  securityErrors: null,
  scaleErrors: null,
  imageErrors: null,
  portErrors: null,
  namespaceErrors: null,
  labelErrors: null,
  annotationErrors: null,

  actions: {
    setImage(uuid) {
      set(this, 'launchConfig.image', uuid);
    },

    setLabels(section, labels) {
      set(this, section + 'Labels', labels);
    },

    setRequestedHostId(hostId) {
      set(this, 'launchConfig.requestedHostId', hostId);
    },

    setUpgrade(upgrade) {
      set(this, 'upgradeOptions', upgrade);
    },

    done() {
      this.sendAction('done');
    },

    cancel() {
      this.sendAction('cancel');
    },

    toggleSeparateLivenessCheck() {
      set(this, 'separateLivenessCheck', !get(this, 'separateLivenessCheck'));
    },

    removeSidekick(idx) {
      var ary = get(this, 'primaryService.secondaryLaunchConfigs');
      ary.removeAt(idx);
    },
  },

  init() {
    window.nec = this;
    this._super(...arguments);

    if (get(this, 'launchConfig') && !get(this, 'launchConfig.environmentFrom')) {
      set(this, 'launchConfig.environmentFrom', []);
    }

    const service = get(this, 'service');

    if (!get(this, 'isSidekick') &&
      service && !get(service, 'scheduling')) {
      set(service, 'scheduling', {
        node: {}
      });
    }

    if (!get(this, 'isSidekick')) {
      this.setProperties({
        name: get(this, 'service.name'),
        description: get(this, 'service.description'),
        scale: get(this, 'service.scale'),
        scheduling: get(this, 'service.scheduling'),
      });
    } else {
      this.setProperties({
{'fraction_non_alphanumeric': 0.1450045829514207, 'fraction_numerical': 0.00036663611365719525, 'mean_word_length': 3.4684684684684686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4738127', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1691, 'n_words': 380}