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

78 lines
1.4 KiB
Vue
Raw Normal View History

<script>
import { mapActions } from 'vuex';
2018-01-03 05:08:14 -05:00
import fileIcon from '../../vue_shared/components/file_icon.vue';
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
},
2018-01-03 05:08:14 -05:00
components: {
fileIcon,
},
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
>
2018-01-03 05:08:14 -05:00
<file-icon
:file-name="tab.name"
:size="16"
>
</file-icon>
2017-11-23 12:16:01 -05:00
{{ tab.name }}
</div>
</li>
</template>