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

70 lines
1.3 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([
'closeFile',
]),
clickFile(tab) {
this.$router.push(`/project${tab.url}`);
},
2017-07-14 21:54:51 -04:00
},
2017-06-30 17:44:48 -04:00
};
</script>
<template>
<li
@click="clickFile(tab)"
>
<button
type="button"
2017-11-23 12:16:01 -05:00
class="multi-file-tab-close"
@click.stop.prevent="closeFile({ file: tab })"
2017-11-23 12:16:01 -05:00
:aria-label="closeLabel"
:class="{
'modified': tab.changed,
}"
:disabled="tab.changed"
>
<i
class="fa"
:class="changedClass"
2017-11-23 12:16:01 -05:00
aria-hidden="true"
>
</i>
</button>
2017-11-23 12:16:01 -05:00
<div
class="multi-file-tab"
:class="{active : tab.active }"
:title="tab.url"
2017-11-23 12:16:01 -05:00
>
{{ tab.name }}
</div>
</li>
</template>