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

75 lines
1.5 KiB
Vue
Raw Normal View History

<script>
2018-01-05 10:45:05 -05:00
import { mapActions } from 'vuex';
import fileIcon from '../../vue_shared/components/file_icon.vue';
2017-06-30 17:44:48 -04:00
2018-01-05 10:45:05 -05:00
export default {
components: {
fileIcon,
2017-07-20 11:37:52 -04:00
},
2018-01-05 10:45:05 -05:00
props: {
tab: {
type: Object,
required: true,
},
},
2018-01-05 10:45:05 -05: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;
},
},
2018-01-05 10:45:05 -05:00
methods: {
...mapActions([
'closeFile',
]),
clickFile(tab) {
this.$router.push(`/project${tab.url}`);
},
},
2018-01-05 10:45:05 -05:00
};
</script>
<template>
2018-01-05 10:45:05 -05:00
<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
>
2018-01-03 05:08:14 -05:00
<file-icon
:file-name="tab.name"
:size="16"
2018-01-05 10:45:05 -05:00
/>
2017-11-23 12:16:01 -05:00
{{ tab.name }}
</div>
</li>
</template>