debian-mirror-gitlab/app/assets/javascripts/ide/components/commit_sidebar/list_item.vue

104 lines
2.7 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
import { mapActions } from 'vuex';
2018-11-08 19:23:39 +05:30
import tooltip from '~/vue_shared/directives/tooltip';
2018-05-09 12:01:36 +05:30
import Icon from '~/vue_shared/components/icon.vue';
2018-11-20 20:47:30 +05:30
import FileIcon from '~/vue_shared/components/file_icon.vue';
2018-10-15 14:42:47 +05:30
import { viewerTypes } from '../../constants';
2020-06-23 00:09:42 +05:30
import getCommitIconMap from '../../commit_icon';
2018-05-09 12:01:36 +05:30
export default {
components: {
Icon,
2018-11-20 20:47:30 +05:30
FileIcon,
2018-05-09 12:01:36 +05:30
},
2018-11-08 19:23:39 +05:30
directives: {
tooltip,
},
2018-05-09 12:01:36 +05:30
props: {
file: {
type: Object,
required: true,
},
2018-10-15 14:42:47 +05:30
keyPrefix: {
type: String,
required: false,
default: '',
},
stagedList: {
type: Boolean,
required: false,
default: false,
},
2018-11-08 19:23:39 +05:30
activeFileKey: {
type: String,
required: false,
default: null,
},
2018-05-09 12:01:36 +05:30
},
computed: {
iconName() {
2019-10-12 21:52:04 +05:30
// name: '-solid' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
2020-04-22 19:07:51 +05:30
// eslint-disable-next-line @gitlab/require-i18n-strings
2018-11-18 11:00:15 +05:30
const suffix = this.stagedList ? '-solid' : '';
return `${getCommitIconMap(this.file).icon}${suffix}`;
2018-05-09 12:01:36 +05:30
},
iconClass() {
2018-11-20 20:47:30 +05:30
return `${getCommitIconMap(this.file).class} ml-auto mr-auto`;
2018-05-09 12:01:36 +05:30
},
2018-11-08 19:23:39 +05:30
fullKey() {
return `${this.keyPrefix}-${this.file.key}`;
},
isActive() {
return this.activeFileKey === this.fullKey;
},
tooltipTitle() {
return this.file.path === this.file.name ? '' : this.file.path;
},
2018-05-09 12:01:36 +05:30
},
methods: {
2020-04-08 14:13:33 +05:30
...mapActions(['discardFileChanges', 'updateViewer', 'openPendingTab']),
2018-10-15 14:42:47 +05:30
openFileInEditor() {
2018-11-18 11:00:15 +05:30
if (this.file.type === 'tree') return null;
2018-10-15 14:42:47 +05:30
return this.openPendingTab({
file: this.file,
2018-11-08 19:23:39 +05:30
keyPrefix: this.keyPrefix,
2018-10-15 14:42:47 +05:30
}).then(changeViewer => {
2018-05-09 12:01:36 +05:30
if (changeViewer) {
2018-10-15 14:42:47 +05:30
this.updateViewer(viewerTypes.diff);
2018-05-09 12:01:36 +05:30
}
});
},
},
};
</script>
<template>
2018-11-08 19:23:39 +05:30
<div class="multi-file-commit-list-item position-relative">
<div
v-tooltip
:title="tooltipTitle"
:class="{
2019-02-15 15:39:39 +05:30
'is-active': isActive,
2018-11-08 19:23:39 +05:30
}"
class="multi-file-commit-list-path w-100 border-0 ml-0 mr-0"
role="button"
2018-10-15 14:42:47 +05:30
@click="openFileInEditor"
>
2018-11-08 19:23:39 +05:30
<span class="multi-file-commit-list-file-path d-flex align-items-center">
2020-06-23 00:09:42 +05:30
<file-icon :file-name="file.name" class="gl-mr-3" />
2019-12-21 20:55:43 +05:30
<template v-if="file.prevName && file.prevName !== file.name">
{{ file.prevName }} &#x2192;
</template>
2019-09-30 21:07:59 +05:30
{{ file.name }}
2018-05-09 12:01:36 +05:30
</span>
2018-11-20 20:47:30 +05:30
<div class="ml-auto d-flex align-items-center">
<div class="d-flex align-items-center ide-commit-list-changed-icon">
2019-12-21 20:55:43 +05:30
<icon :name="iconName" :size="16" :class="iconClass" />
2018-11-20 20:47:30 +05:30
</div>
</div>
2018-11-08 19:23:39 +05:30
</div>
2018-05-09 12:01:36 +05:30
</div>
</template>