summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/components/repo_tab.vue
blob: 712d64c236f397f47cb2f960e999de11c0114969 (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
<script>
import Store from '../stores/repo_store';

const RepoTab = {
  props: {
    tab: {
      type: Object,
      required: true,
    },
  },

  computed: {
    changedClass() {
      const tabChangedObj = {
        'fa-times': !this.tab.changed,
        'fa-circle': this.tab.changed,
      };
      return tabChangedObj;
    },
  },

  methods: {
    tabClicked: Store.setActiveFiles,

    xClicked(file) {
      if (file.changed) return;
      this.$emit('xclicked', file);
    },
  },
};

export default RepoTab;
</script>

<template>
<li>
  <a href="#" class="close" @click.prevent="xClicked(tab)" v-if="!tab.loading">
    <i class="fa" :class="changedClass"></i>
  </a>

  <a href="#" class="repo-tab" v-if="!tab.loading" :title="tab.url" @click.prevent="tabClicked(tab)">{{tab.name}}</a>

  <i v-if="tab.loading" class="fa fa-spinner fa-spin"></i>
</li>
</template>