All files / app/assets/javascripts/ide/components repo_tabs.vue

40% Statements 4/10
0% Branches 0/2
33.33% Functions 1/3
40% Lines 4/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  1x 1x 1x                                                                                 8x              
<script>
import { GlTabs } from '@gitlab/ui';
import { mapActions, mapGetters } from 'vuex';
import RepoTab from './repo_tab.vue';
 
export default {
  components: {
    RepoTab,
    GlTabs,
  },
  props: {
    activeFile: {
      type: Object,
      required: true,
    },
    files: {
      type: Array,
      required: true,
    },
    viewer: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapGetters(['getUrlForPath']),
  },
  methods: {
    ...mapActions(['updateViewer', 'removePendingTab']),
    openFileViewer(viewer) {
      this.updateViewer(viewer);
 
      if (this.activeFile.pending) {
        return this.removePendingTab(this.activeFile).then(() => {
          this.$router.push(this.getUrlForPath(this.activeFile.path));
        });
      }
 
      return null;
    },
  },
};
</script>
 
<template>
  <div class="multi-file-tabs">
    <gl-tabs>
      <repo-tab v-for="tab in files" :key="tab.key" :tab="tab" />
    </gl-tabs>
  </div>
</template>