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

106 lines
2.8 KiB
Vue
Raw Normal View History

2018-12-05 23:21:45 +05:30
<script>
import { mapGetters } from 'vuex';
import { n__, __, sprintf } from '~/locale';
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;
if (this.folderUnstagedCount > 0 && this.folderStagedCount === 0) {
return n__('%d unstaged change', '%d unstaged changes', this.folderUnstagedCount);
} else if (this.folderUnstagedCount === 0 && this.folderStagedCount > 0) {
return n__('%d staged change', '%d staged changes', this.folderStagedCount);
}
2020-03-13 15:44:24 +05:30
return sprintf(__('%{staged} staged and %{unstaged} unstaged changes'), {
2018-12-05 23:21:45 +05:30
unstaged: this.folderUnstagedCount,
staged: this.folderStagedCount,
});
},
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>