<commit_before>import { inject as service } from '@ember/service';
import { gt } from '@ember/object/computed';
import { get, set, computed } from '@ember/object';
import { parseSi } from 'shared/utils/parse-unit';
import Component from '@ember/component';
import ViewNewEdit from 'shared/mixins/view-new-edit';
import ChildHook from 'shared/mixins/child-hook';
import layout from './template';

export default Component.extend(ViewNewEdit, ChildHook, {
  layout,
  intl: service(),
  scope: service(),

  model: null,
  namespace: null,
  persistentVolumes: null,
  storageClasses: null,
  selectNamespace: true,
  actuallySave: true,
  useStorageClass: true,
  capacity: null,

  titleKey: 'cruPersistentVolumeClaim.title',

  actions: {
    cancel: function() {
      this.sendAction('cancel');
    },
  },

  didReceiveAttrs() {
    if ( !get(this, 'persistentVolumes') ) {
      set(this, 'persistentVolumes', get(this, 'clusterStore').all('persistentVolume'));
    }

    if ( !get(this, 'storageClasses') ) {
      set(this, 'storageClasses', get(this, 'clusterStore').all('storageClass'));
    }

    if ( !get(this,'selectNamespace') ) {
      set(this, 'primaryResource.namespaceId', get(this,'namespace.id'));
    }

    if ( get(this,'isNew') ) {
      const capacity = get(this, 'primaryResource.resources.requests.storage');
      if ( capacity ) {
        const bytes = parseSi(capacity);
        const gib = bytes/(1024**3);
        set(this, 'capacity', gib);
      }

      if ( !get(this, 'canUseStorageClass')) {
        set(this, 'useStorageClass', false);
      }
    } else {<commit_msg>Fix pvc issue with new namespace<commit_after>import { inject as service } from '@ember/service';
import { gt } from '@ember/object/computed';
import { get, set, computed } from '@ember/object';
import { parseSi } from 'shared/utils/parse-unit';
import Component from '@ember/component';
import ViewNewEdit from 'shared/mixins/view-new-edit';
import ChildHook from 'shared/mixins/child-hook';
import layout from './template';

export default Component.extend(ViewNewEdit, ChildHook, {
  layout,
  intl: service(),
  scope: service(),

  model: null,
  namespace: null,
  persistentVolumes: null,
  storageClasses: null,
  selectNamespace: true,
  actuallySave: true,
  useStorageClass: true,
  capacity: null,

  titleKey: 'cruPersistentVolumeClaim.title',

  actions: {
    cancel: function() {
      this.sendAction('cancel');
    },
  },

  didReceiveAttrs() {
    if ( !get(this, 'persistentVolumes') ) {
      set(this, 'persistentVolumes', get(this, 'clusterStore').all('persistentVolume'));
    }

    if ( !get(this, 'storageClasses') ) {
      set(this, 'storageClasses', get(this, 'clusterStore').all('storageClass'));
    }

    if ( !get(this,'selectNamespace') ) {
      set(this, 'primaryResource.namespaceId', get(this,'namespace.id') || get(this,'namespace.name'));
    }

    if ( get(this,'isNew') ) {
      const capacity = get(this, 'primaryResource.resources.requests.storage');
      if ( capacity ) {
        const bytes = parseSi(capacity);
        const gib = bytes/(1024**3);
        set(this, 'capacity', gib);
      }

      if ( !get(this, 'canUseStorageClass')) {
        set(this, 'useStorageClass', false);
      }
    } else {
{'fraction_non_alphanumeric': 0.15478739675741818, 'fraction_numerical': 0.0030590394616090547, 'mean_word_length': 3.691535150645624, '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': '5136473', 'n_tokens_mistral': 1022, 'n_tokens_neox': 993, 'n_words': 228}