debian-mirror-gitlab/app/assets/javascripts/repo/components/repo_tab.vue

64 lines
1.1 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
import Store from '../stores/repo_store';
const RepoTab = {
props: {
tab: {
type: Object,
required: true,
},
},
computed: {
closeLabel() {
if (this.tab.changed) {
return `${this.tab.name} changed`;
}
return `Close ${this.tab.name}`;
},
changedClass() {
const tabChangedObj = {
'fa-times close-icon': !this.tab.changed,
'fa-circle unsaved-icon': this.tab.changed,
};
return tabChangedObj;
},
},
methods: {
tabClicked: Store.setActiveFiles,
closeTab(file) {
if (file.changed) return;
this.$emit('tabclosed', file);
},
},
};
export default RepoTab;
</script>
<template>
<li @click="tabClicked(tab)">
<a
href="#0"
class="close"
@click.stop.prevent="closeTab(tab)"
:aria-label="closeLabel">
<i
class="fa"
:class="changedClass"
aria-hidden="true">
</i>
</a>
<a
href="#"
class="repo-tab"
:title="tab.url"
@click.prevent="tabClicked(tab)">
{{tab.name}}
</a>
</li>
</template>