gitlab-org--gitlab-foss/app/assets/javascripts/repo/repo_tab.vue

45 lines
867 B
Vue
Raw Normal View History

<script>
import RepoStore from './repo_store';
2017-06-30 17:44:48 -04:00
2017-07-14 21:54:51 -04:00
const RepoTab = {
2017-06-30 17:44:48 -04:00
props: {
name: 'repo-tab',
tab: Object,
saved: true,
},
computed: {
changedClass() {
const tabChangedObj = {
'fa-times': !this.tab.changed,
'fa-circle': this.tab.changed,
};
return tabChangedObj;
},
},
2017-06-30 17:44:48 -04:00
methods: {
2017-07-20 11:00:47 -04:00
tabClicked: RepoStore.setActiveFiles.bind(RepoStore),
2017-06-30 17:44:48 -04:00
xClicked(file) {
if (file.changed) return;
RepoStore.removeFromOpenedFiles(file);
2017-07-14 21:54:51 -04:00
},
},
2017-06-30 17:44:48 -04:00
};
2017-07-14 21:54:51 -04:00
export default RepoTab;
</script>
<template>
<li>
<a href="#" @click.prevent="xClicked(tab)" v-if="!tab.loading">
<i class="fa" :class="changedClass"></i>
</a>
<a href="#" 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>