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

65 lines
1.6 KiB
Vue
Raw Normal View History

2019-03-02 22:35:43 +05:30
<script>
import Icon from '~/vue_shared/components/icon.vue';
import { n__ } from '~/locale';
2020-04-08 14:13:33 +05:30
import { isNumber } from 'lodash';
2019-03-02 22:35:43 +05:30
export default {
components: { Icon },
props: {
addedLines: {
type: Number,
required: true,
},
removedLines: {
type: Number,
required: true,
},
diffFilesLength: {
type: Number,
required: false,
default: null,
},
},
computed: {
filesText() {
2020-03-09 13:42:32 +05:30
return n__('file', 'files', this.diffFilesLength);
2019-03-02 22:35:43 +05:30
},
isCompareVersionsHeader() {
return Boolean(this.diffFilesLength);
},
2020-03-09 13:42:32 +05:30
hasDiffFiles() {
return isNumber(this.diffFilesLength) && this.diffFilesLength >= 0;
},
2019-03-02 22:35:43 +05:30
},
};
</script>
<template>
<div
class="diff-stats"
:class="{
'is-compare-versions-header d-none d-lg-inline-flex': isCompareVersionsHeader,
'd-inline-flex': !isCompareVersionsHeader,
}"
>
2020-03-09 13:42:32 +05:30
<div v-if="hasDiffFiles" class="diff-stats-group">
2019-03-02 22:35:43 +05:30
<icon name="doc-code" class="diff-stats-icon text-secondary" />
2020-03-09 13:42:32 +05:30
<span class="text-secondary bold">{{ diffFilesLength }} {{ filesText }}</span>
2019-03-02 22:35:43 +05:30
</div>
2020-03-09 13:42:32 +05:30
<div
class="diff-stats-group cgreen d-flex align-items-center"
:class="{ bold: isCompareVersionsHeader }"
>
<span>+</span>
<span class="js-file-addition-line">{{ addedLines }}</span>
2019-03-02 22:35:43 +05:30
</div>
2020-03-09 13:42:32 +05:30
<div
class="diff-stats-group cred d-flex align-items-center"
:class="{ bold: isCompareVersionsHeader }"
>
<span>-</span>
<span class="js-file-deletion-line">{{ removedLines }}</span>
2019-03-02 22:35:43 +05:30
</div>
</div>
</template>