2017-07-20 11:20:48 -04:00
|
|
|
<script>
|
2017-10-26 06:14:31 -04:00
|
|
|
import { mapActions } from 'vuex';
|
2017-06-30 17:44:48 -04:00
|
|
|
|
2017-10-26 06:14:31 -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
|
|
|
},
|
|
|
|
|
2017-07-17 09:15:35 -04:00
|
|
|
computed: {
|
2017-08-10 15:17:38 -04:00
|
|
|
closeLabel() {
|
2017-10-26 11:44:26 -04:00
|
|
|
if (this.tab.changed || this.tab.tempFile) {
|
2017-08-10 15:17:38 -04:00
|
|
|
return `${this.tab.name} changed`;
|
|
|
|
}
|
|
|
|
return `Close ${this.tab.name}`;
|
|
|
|
},
|
2017-07-17 09:15:35 -04:00
|
|
|
changedClass() {
|
|
|
|
const tabChangedObj = {
|
2017-10-12 05:55:11 -04:00
|
|
|
'fa-times close-icon': !this.tab.changed && !this.tab.tempFile,
|
|
|
|
'fa-circle unsaved-icon': this.tab.changed || this.tab.tempFile,
|
2017-07-17 09:15:35 -04:00
|
|
|
};
|
2017-07-17 09:44:19 -04:00
|
|
|
return tabChangedObj;
|
|
|
|
},
|
2017-07-17 09:15:35 -04:00
|
|
|
},
|
|
|
|
|
2017-06-30 17:44:48 -04:00
|
|
|
methods: {
|
2017-10-26 06:14:31 -04:00
|
|
|
...mapActions([
|
|
|
|
'setFileActive',
|
|
|
|
'closeFile',
|
|
|
|
]),
|
2017-07-14 21:54:51 -04:00
|
|
|
},
|
2017-06-30 17:44:48 -04:00
|
|
|
};
|
2017-07-20 11:20:48 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2017-10-13 05:08:10 -04:00
|
|
|
<li
|
|
|
|
:class="{ active : tab.active }"
|
2017-10-26 06:14:31 -04:00
|
|
|
@click="setFileActive(tab)"
|
2017-10-13 05:08:10 -04:00
|
|
|
>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="close-btn"
|
2017-10-26 11:44:26 -04:00
|
|
|
@click.stop.prevent="closeFile({ file: tab })"
|
2017-10-13 05:08:10 -04:00
|
|
|
:aria-label="closeLabel">
|
|
|
|
<i
|
|
|
|
class="fa"
|
|
|
|
:class="changedClass"
|
|
|
|
aria-hidden="true">
|
|
|
|
</i>
|
|
|
|
</button>
|
2017-07-20 11:20:48 -04:00
|
|
|
|
2017-10-13 05:08:10 -04:00
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="repo-tab"
|
|
|
|
:title="tab.url"
|
2017-10-26 11:44:26 -04:00
|
|
|
@click.prevent.stop="setFileActive(tab)">
|
2017-10-13 05:08:10 -04:00
|
|
|
{{tab.name}}
|
|
|
|
</a>
|
|
|
|
</li>
|
2017-07-20 11:20:48 -04:00
|
|
|
</template>
|