<commit_before><template>

  <core-base :topLevelPageName="topLevelPageName" :appBarTitle="$tr('learnTitle')">
    <div slot="app-bar-actions">
      <channel-switcher @switch="switchChannel"/>
      <router-link :to="searchPage">
        <ui-icon-button
          icon="search"
          type="secondary"
          color="white"
          :ariaLabel="$tr('search')"/>
      </router-link>
    </div>
    <div slot="tabs" v-if="!isSearchPage">
      <tabs :items="learnTabs" type="icon-and-text" @tabclicked="handleTabClick"/>
    </div>
    <div slot="content">
      <breadcrumbs/>
      <component :is="currentPage"/>
    </div>

  </core-base>

</template>


<script>

  const constants = require('../state/constants');
  const PageNames = constants.PageNames;
  const store = require('../state/store');
  const TopLevelPageNames = require('kolibri.coreVue.vuex.constants').TopLevelPageNames;

  module.exports = {
    $trNameSpace: 'learn',
    $trs: {
      learnTitle: 'Learn',
      recommended: 'Recommended',
      topics: 'Topics',
      search: 'search',
    },
    components: {
      'explore-page': require('./explore-page'),
      'content-page': require('./content-page'),
      'learn-page': require('./learn-page'),
      'scratchpad-page': require('./scratchpad-page'),
      'content-unavailable-page': require('./content-unavailable-page'),
      'core-base': require('kolibri.coreVue.components.coreBase'),
      'ui-icon-button': require('keen-ui/src/UiIconButton'),
      'channel-switcher': require('kolibri.coreVue.components.channelSwitcher'),
      'breadcrumbs': require('./breadcrumbs'),
      'search-page': require('./search-page'),
      'tabs': require('kolibri.coreVue.components.tabs'),
    },
    methods: {
      switchChannel(channelId) {
        if (this.pageName === constants.PageNames.SEARCH) {
          if (this.searchTerm) {
            this.$router.replace({
              name: constants.PageNames.SEARCH,
              params: { channel_id: channelId },
              query: { query: this.searchTerm },
            });
          } else {
            this.$router.replace({
              name: constants.PageNames.SEARCH,
              params: { channel_id: channelId },
            });
          }
        } else if (this.pageName === constants.PageNames.LEARN_CHANNEL) {
          this.$router.push({
            name: constants.PageNames.LEARN_CHANNEL,
            params: { channel_id: channelId },
          });
        } else {
          this.$router.push({
            name: constants.PageNames.EXPLORE_CHANNEL,
            params: { channel_id: channelId },
          });
        }
      },
      handleTabClick(tabIndex) {
        switch (tabIndex) {
          case 0:
            this.$router.push({ name: constants.PageNames.LEARN_ROOT });
            return;

          case 1:
            this.$router.push({ name: constants.PageNames.EXPLORE_ROOT });
            return;

          default:
            return;
        }
      },
    },
    computed: {
      topLevelPageName() {
        return TopLevelPageNames.LEARN;
      },
      currentPage() {
        if (this.pageName === PageNames.EXPLORE_CHANNEL ||
          this.pageName === PageNames.EXPLORE_TOPIC) {
          return 'explore-page';
        }
        if (this.pageName === PageNames.EXPLORE_CONTENT ||
          this.pageName === PageNames.LEARN_CONTENT) {
          return 'content-page';
        }
        if (this.pageName === PageNames.LEARN_CHANNEL) {
          return 'learn-page';<commit_msg>Simplify switch channel routing.<commit_after><template>

  <core-base :topLevelPageName="topLevelPageName" :appBarTitle="$tr('learnTitle')">
    <div slot="app-bar-actions">
      <channel-switcher @switch="switchChannel"/>
      <router-link :to="searchPage">
        <ui-icon-button
          icon="search"
          type="secondary"
          color="white"
          :ariaLabel="$tr('search')"/>
      </router-link>
    </div>
    <div slot="tabs" v-if="!isSearchPage">
      <tabs :items="learnTabs" type="icon-and-text" @tabclicked="handleTabClick"/>
    </div>
    <div slot="content">
      <breadcrumbs/>
      <component :is="currentPage"/>
    </div>

  </core-base>

</template>


<script>

  const constants = require('../state/constants');
  const PageNames = constants.PageNames;
  const store = require('../state/store');
  const TopLevelPageNames = require('kolibri.coreVue.vuex.constants').TopLevelPageNames;

  module.exports = {
    $trNameSpace: 'learn',
    $trs: {
      learnTitle: 'Learn',
      recommended: 'Recommended',
      topics: 'Topics',
      search: 'search',
    },
    components: {
      'explore-page': require('./explore-page'),
      'content-page': require('./content-page'),
      'learn-page': require('./learn-page'),
      'scratchpad-page': require('./scratchpad-page'),
      'content-unavailable-page': require('./content-unavailable-page'),
      'core-base': require('kolibri.coreVue.components.coreBase'),
      'ui-icon-button': require('keen-ui/src/UiIconButton'),
      'channel-switcher': require('kolibri.coreVue.components.channelSwitcher'),
      'breadcrumbs': require('./breadcrumbs'),
      'search-page': require('./search-page'),
      'tabs': require('kolibri.coreVue.components.tabs'),
    },
    methods: {
      switchChannel(channelId) {
        let page;
        switch (this.pageName) {
          case constants.PageNames.SEARCH:
            page = constants.PageNames.SEARCH;
            if (this.searchTerm) {
              this.$router.push({
                name: page,
                params: { channel_id: channelId },
                query: { query: this.searchTerm },
              });
              return;
            }
            break;

          case constants.PageNames.LEARN_CHANNEL:
            page = constants.PageNames.LEARN_CHANNEL;
            break;

          default:
            page = constants.PageNames.EXPLORE_CHANNEL;
        }

        this.$router.push({
          name: page,
          params: { channel_id: channelId },
        });
      },
      handleTabClick(tabIndex) {
        switch (tabIndex) {
          case 0:
            this.$router.push({ name: constants.PageNames.LEARN_ROOT });
            return;

          case 1:
            this.$router.push({ name: constants.PageNames.EXPLORE_ROOT });
            return;

          default:
            return;
        }
      },
    },
    computed: {
      topLevelPageName() {
        return TopLevelPageNames.LEARN;
      },
      currentPage() {
        if (this.pageName === PageNames.EXPLORE_CHANNEL ||
          this.pageName === PageNames.EXPLORE_TOPIC) {
          return 'explore-page';
        }
        if (this.pageName === PageNames.EXPLORE_CONTENT ||
          this.pageName === PageNames.LEARN_CONTENT) {
          return 'content-page';
        }
        if (this.pageName === PageNames.LEARN_CHANNEL) {
          return 'learn-page';
{'fraction_non_alphanumeric': 0.15077764976958524, 'fraction_numerical': 0.000576036866359447, 'mean_word_length': 2.1326116373477673, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '6978471', 'n_tokens_mistral': 2064, 'n_tokens_neox': 2048, 'n_words': 323}