summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/repo_tabs.vue
blob: 1b7f149097b7e79e57eff81d2d431f38a76fd7f2 (plain)
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
53
54
55
56
<script>
import { mapActions } from 'vuex';
import RepoTab from './repo_tab.vue';
import router from '../ide_router';

export default {
  components: {
    RepoTab,
  },
  props: {
    activeFile: {
      type: Object,
      required: true,
    },
    files: {
      type: Array,
      required: true,
    },
    viewer: {
      type: String,
      required: true,
    },
    hasChanges: {
      type: Boolean,
      required: true,
    },
    mergeRequestId: {
      type: String,
      required: false,
      default: '',
    },
  },
  methods: {
    ...mapActions(['updateViewer', 'removePendingTab']),
    openFileViewer(viewer) {
      this.updateViewer(viewer);

      if (this.activeFile.pending) {
        return this.removePendingTab(this.activeFile).then(() => {
          router.push(`/project${this.activeFile.url}`);
        });
      }

      return null;
    },
  },
};
</script>

<template>
  <div class="multi-file-tabs">
    <ul ref="tabsScroller" class="list-unstyled append-bottom-0">
      <repo-tab v-for="tab in files" :key="tab.key" :tab="tab" />
    </ul>
  </div>
</template>