2018-12-05 23:21:45 +05:30
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
2020-04-08 14:13:33 +05:30
|
|
|
import { n__ } from '~/locale';
|
2018-12-05 23:21:45 +05:30
|
|
|
import tooltip from '~/vue_shared/directives/tooltip';
|
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import ChangedFileIcon from '~/vue_shared/components/changed_file_icon.vue';
|
|
|
|
import NewDropdown from './new_dropdown/index.vue';
|
|
|
|
import MrFileIcon from './mr_file_icon.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'FileRowExtra',
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
NewDropdown,
|
|
|
|
ChangedFileIcon,
|
|
|
|
MrFileIcon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
file: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
dropdownOpen: {
|
2018-12-05 23:21:45 +05:30
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters([
|
|
|
|
'getChangesInFolder',
|
|
|
|
'getUnstagedFilesCountForPath',
|
|
|
|
'getStagedFilesCountForPath',
|
|
|
|
]),
|
2019-12-21 20:55:43 +05:30
|
|
|
isTree() {
|
|
|
|
return this.file.type === 'tree';
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
folderUnstagedCount() {
|
|
|
|
return this.getUnstagedFilesCountForPath(this.file.path);
|
|
|
|
},
|
|
|
|
folderStagedCount() {
|
|
|
|
return this.getStagedFilesCountForPath(this.file.path);
|
|
|
|
},
|
|
|
|
changesCount() {
|
|
|
|
return this.getChangesInFolder(this.file.path);
|
|
|
|
},
|
|
|
|
folderChangesTooltip() {
|
|
|
|
if (this.changesCount === 0) return undefined;
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
return n__('%d changed file', '%d changed files', this.changesCount);
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
showTreeChangesCount() {
|
2019-12-21 20:55:43 +05:30
|
|
|
return this.isTree && this.changesCount > 0 && !this.file.opened;
|
|
|
|
},
|
|
|
|
isModified() {
|
|
|
|
return this.file.changed || this.file.tempFile || this.file.staged || this.file.prevPath;
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
showChangedFileIcon() {
|
2019-12-21 20:55:43 +05:30
|
|
|
return !this.isTree && this.isModified;
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="float-right ide-file-icon-holder">
|
2019-02-15 15:39:39 +05:30
|
|
|
<mr-file-icon v-if="file.mrChange" />
|
|
|
|
<span v-if="showTreeChangesCount" class="ide-tree-changes">
|
2018-12-05 23:21:45 +05:30
|
|
|
{{ changesCount }}
|
|
|
|
<icon
|
|
|
|
v-tooltip
|
|
|
|
:title="folderChangesTooltip"
|
|
|
|
:size="12"
|
|
|
|
data-container="body"
|
|
|
|
data-placement="right"
|
|
|
|
name="file-modified"
|
2019-12-21 20:55:43 +05:30
|
|
|
class="prepend-left-5 ide-file-modified"
|
2018-12-05 23:21:45 +05:30
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<changed-file-icon
|
|
|
|
v-else-if="showChangedFileIcon"
|
|
|
|
:file="file"
|
|
|
|
:show-tooltip="true"
|
2019-12-04 20:38:33 +05:30
|
|
|
:show-staged-icon="false"
|
2018-12-05 23:21:45 +05:30
|
|
|
/>
|
|
|
|
<new-dropdown
|
|
|
|
:type="file.type"
|
|
|
|
:path="file.path"
|
2019-07-07 11:18:12 +05:30
|
|
|
:is-open="dropdownOpen"
|
2018-12-05 23:21:45 +05:30
|
|
|
class="prepend-left-8"
|
2019-07-07 11:18:12 +05:30
|
|
|
v-on="$listeners"
|
2018-12-05 23:21:45 +05:30
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|