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

96 lines
2.3 KiB
Vue
Raw Normal View History

2018-12-05 23:21:45 +05:30
<script>
import { mapGetters } from 'vuex';
2021-01-29 00:20:46 +05:30
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
2020-04-08 14:13:33 +05:30
import { n__ } from '~/locale';
2018-12-05 23:21:45 +05:30
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: {
2021-01-29 00:20:46 +05:30
GlTooltip: GlTooltipDirective,
2018-12-05 23:21:45 +05:30
},
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2018-12-05 23:21:45 +05:30
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 }}
2020-11-24 15:15:51 +05:30
<gl-icon
2021-01-29 00:20:46 +05:30
v-gl-tooltip.left.viewport
2018-12-05 23:21:45 +05:30
:title="folderChangesTooltip"
:size="12"
data-container="body"
data-placement="right"
name="file-modified"
2020-07-28 23:09:34 +05:30
class="gl-ml-2 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"
2020-06-23 00:09:42 +05:30
class="gl-ml-3"
2019-07-07 11:18:12 +05:30
v-on="$listeners"
2018-12-05 23:21:45 +05:30
/>
</div>
</template>