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

63 lines
1.1 KiB
Vue
Raw Normal View History

<script>
import { mapActions } from 'vuex';
2017-06-30 17:44:48 -04:00
export default {
2017-06-30 17:44:48 -04:00
props: {
2017-07-20 11:37:52 -04:00
tab: {
type: Object,
required: true,
},
2017-06-30 17:44:48 -04:00
},
computed: {
closeLabel() {
if (this.tab.changed || this.tab.tempFile) {
return `${this.tab.name} changed`;
}
return `Close ${this.tab.name}`;
},
changedClass() {
const tabChangedObj = {
'fa-times close-icon': !this.tab.changed && !this.tab.tempFile,
'fa-circle unsaved-icon': this.tab.changed || this.tab.tempFile,
};
return tabChangedObj;
},
},
2017-06-30 17:44:48 -04:00
methods: {
...mapActions([
'setFileActive',
'closeFile',
]),
2017-07-14 21:54:51 -04:00
},
2017-06-30 17:44:48 -04:00
};
</script>
<template>
<li
:class="{ active : tab.active }"
@click="setFileActive(tab)"
>
<button
type="button"
class="close-btn"
@click.stop.prevent="closeFile({ file: tab })"
:aria-label="closeLabel">
<i
class="fa"
:class="changedClass"
aria-hidden="true">
</i>
</button>
<a
href="#"
class="repo-tab"
:title="tab.url"
@click.prevent.stop="setFileActive(tab)">
{{tab.name}}
</a>
</li>
</template>