debian-mirror-gitlab/app/assets/javascripts/diffs/components/diff_file_row.vue

69 lines
1.6 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
/**
* This component is an iterative step towards refactoring and simplifying `vue_shared/components/file_row.vue`
* https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23720
*/
2020-11-24 15:15:51 +05:30
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2020-03-13 15:44:24 +05:30
import FileRow from '~/vue_shared/components/file_row.vue';
import ChangedFileIcon from '~/vue_shared/components/changed_file_icon.vue';
2020-11-24 15:15:51 +05:30
import FileRowStats from './file_row_stats.vue';
2020-03-13 15:44:24 +05:30
export default {
name: 'DiffFileRow',
components: {
FileRow,
FileRowStats,
ChangedFileIcon,
},
2020-11-24 15:15:51 +05:30
mixins: [glFeatureFlagsMixin()],
2020-03-13 15:44:24 +05:30
props: {
file: {
type: Object,
required: true,
},
hideFileStats: {
type: Boolean,
required: true,
},
2020-07-28 23:09:34 +05:30
currentDiffFileId: {
type: String,
required: false,
default: null,
},
2020-11-24 15:15:51 +05:30
viewedFiles: {
type: Object,
required: false,
default: () => ({}),
},
2020-03-13 15:44:24 +05:30
},
computed: {
showFileRowStats() {
return !this.hideFileStats && this.file.type === 'blob';
},
2020-11-24 15:15:51 +05:30
fileClasses() {
return this.file.type === 'blob' && !this.viewedFiles[this.file.fileHash]
? 'gl-font-weight-bold'
: '';
},
isActive() {
return this.currentDiffFileId === this.file.fileHash;
},
2020-03-13 15:44:24 +05:30
},
};
</script>
<template>
2020-07-28 23:09:34 +05:30
<file-row
:file="file"
v-bind="$attrs"
2020-11-24 15:15:51 +05:30
:class="{ 'is-active': isActive }"
2020-07-28 23:09:34 +05:30
class="diff-file-row"
2021-01-29 00:20:46 +05:30
truncate-middle
2020-11-24 15:15:51 +05:30
:file-classes="fileClasses"
2020-07-28 23:09:34 +05:30
v-on="$listeners"
>
2020-03-13 15:44:24 +05:30
<file-row-stats v-if="showFileRowStats" :file="file" class="mr-1" />
2020-04-08 14:13:33 +05:30
<changed-file-icon :file="file" :size="16" :show-tooltip="true" />
2020-03-13 15:44:24 +05:30
</file-row>
</template>