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

68 lines
1.7 KiB
Vue
Raw Normal View History

2019-03-02 22:35:43 +05:30
<script>
2020-10-24 23:57:45 +05:30
import { isNumber } from 'lodash';
2019-03-02 22:35:43 +05:30
import Icon from '~/vue_shared/components/icon.vue';
import { n__ } from '~/locale';
export default {
components: { Icon },
props: {
addedLines: {
type: Number,
required: true,
},
removedLines: {
type: Number,
required: true,
},
2020-10-24 23:57:45 +05:30
diffFilesCountText: {
type: String,
2019-03-02 22:35:43 +05:30
required: false,
default: null,
},
},
computed: {
2020-10-24 23:57:45 +05:30
diffFilesLength() {
return parseInt(this.diffFilesCountText, 10);
},
2019-03-02 22:35:43 +05:30
filesText() {
2020-03-13 15:44:24 +05:30
return n__('file', 'files', this.diffFilesLength);
2019-03-02 22:35:43 +05:30
},
isCompareVersionsHeader() {
2020-10-24 23:57:45 +05:30
return Boolean(this.diffFilesCountText);
2019-03-02 22:35:43 +05:30
},
2020-03-13 15:44:24 +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-13 15:44:24 +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-10-24 23:57:45 +05:30
<span class="text-secondary bold">{{ diffFilesCountText }} {{ filesText }}</span>
2019-03-02 22:35:43 +05:30
</div>
2020-03-13 15:44:24 +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-13 15:44:24 +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>