<commit_before><template>

  <div>
    <div class="options">
      <k-radio-button
        :label="$tr('network')"
        v-model="source"
        value="network"
        :disabled="disableUi || kolibriStudioIsOffline"
        :autofocus="!kolibriStudioIsOffline"
      />
      <k-radio-button
        :label="$tr('localDrives')"
        v-model="source"
        value="local"
        :disabled="disableUi"
      />
    </div>

    <div class="core-modal-buttons">
      <k-button
        @click="$emit('cancel')"
        appearance="flat-button"
        :text="$tr('cancel')"
      />
      <k-button
        @click="goForward"
        :primary="true"
        :disabled="disableUi"
        :text="$tr('continue')"
      />
    </div>
  </div>

</template>


<script>

  import kRadioButton from 'kolibri.coreVue.components.kRadioButton';
  import kButton from 'kolibri.coreVue.components.kButton';
  import { RemoteChannelResource } from 'kolibri.resources';
  import {
    goForwardFromSelectImportSourceModal,
    LOCAL_DRIVE,
    KOLIBRI_STUDIO,
  } from '../../../state/actions/contentWizardActions';

  export default {
    name: 'selectImportSourceModal',
    components: {
      kButton,
      kRadioButton,
    },
    data() {
      return {
        source: KOLIBRI_STUDIO,
        disableUi: true,
        kolibriStudioIsOffline: false,
      };
    },
    created() {
      RemoteChannelResource.getKolibriStudioStatus().then(({ entity }) => {
        if (entity.status === 'offline') {
          this.source = LOCAL_DRIVE;
          this.kolibriStudioIsOffline = true;
        }
        this.disableUi = false;
      });
    },
    $trs: {
      cancel: 'Cancel',
      continue: 'Continue',
      network: 'Kolibri Studio',
      localDrives: 'Attached drive or memory card',
    },
    methods: {
      goForward() {
        this.goForwardFromSelectImportSourceModal(this.source);
      },
    },
    vuex: {
      actions: {
        goForwardFromSelectImportSourceModal,
      },
    },
  };

</script>


<style lang="stylus" scoped>

  .options
    margin: 2em 0

</style><commit_msg>Add guard for moving forward on import source modal<commit_after><template>

  <div>
    <div class="options">
      <k-radio-button
        :label="$tr('network')"
        v-model="source"
        value="network"
        :disabled="formIsDisabled || kolibriStudioIsOffline"
        :autofocus="!kolibriStudioIsOffline"
      />
      <k-radio-button
        :label="$tr('localDrives')"
        v-model="source"
        value="local"
        :disabled="formIsDisabled"
      />
    </div>

    <div class="core-modal-buttons">
      <k-button
        @click="$emit('cancel')"
        appearance="flat-button"
        :text="$tr('cancel')"
      />
      <k-button
        @click="goForward"
        :primary="true"
        :disabled="formIsDisabled"
        :text="$tr('continue')"
      />
    </div>
  </div>

</template>


<script>

  import kRadioButton from 'kolibri.coreVue.components.kRadioButton';
  import kButton from 'kolibri.coreVue.components.kButton';
  import { RemoteChannelResource } from 'kolibri.resources';
  import {
    goForwardFromSelectImportSourceModal,
    LOCAL_DRIVE,
    KOLIBRI_STUDIO,
  } from '../../../state/actions/contentWizardActions';

  export default {
    name: 'selectImportSourceModal',
    components: {
      kButton,
      kRadioButton,
    },
    data() {
      return {
        source: KOLIBRI_STUDIO,
        formIsDisabled: true,
        kolibriStudioIsOffline: false,
      };
    },
    created() {
      RemoteChannelResource.getKolibriStudioStatus().then(({ entity }) => {
        if (entity.status === 'offline') {
          this.source = LOCAL_DRIVE;
          this.kolibriStudioIsOffline = true;
        }
        this.formIsDisabled = false;
      });
    },
    $trs: {
      cancel: 'Cancel',
      continue: 'Continue',
      network: 'Kolibri Studio',
      localDrives: 'Attached drive or memory card',
    },
    methods: {
      goForward() {
        if (!this.formIsDisabled) {
          this.goForwardFromSelectImportSourceModal(this.source);
        }
      },
    },
    vuex: {
      actions: {
        goForwardFromSelectImportSourceModal,
      },
    },
  };

</script>


<style lang="stylus" scoped>

  .options
    margin: 2em 0

</style>
{'fraction_non_alphanumeric': 0.14090382387022016, 'fraction_numerical': 0.0009269988412514484, 'mean_word_length': 2.230538922155689, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, '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': '4338717', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1374, 'n_words': 221}