2019-01-30 03:21:26 +00:00
|
|
|
<script>
|
2020-01-21 21:08:54 +00:00
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2019-01-30 03:21:26 +00:00
|
|
|
import { n__ } from '~/locale';
|
2020-02-24 09:08:51 +00:00
|
|
|
import { isNumber } from 'lodash';
|
2019-01-30 03:21:26 +00:00
|
|
|
|
|
|
|
export default {
|
2020-01-21 21:08:54 +00:00
|
|
|
components: { Icon },
|
2019-01-30 03:21:26 +00:00
|
|
|
props: {
|
|
|
|
addedLines: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
removedLines: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
diffFilesLength: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
2020-02-04 15:08:40 +00:00
|
|
|
default: null,
|
2019-01-30 03:21:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
filesText() {
|
2020-02-05 09:08:43 +00:00
|
|
|
return n__('file', 'files', this.diffFilesLength);
|
2019-01-30 03:21:26 +00:00
|
|
|
},
|
|
|
|
isCompareVersionsHeader() {
|
|
|
|
return Boolean(this.diffFilesLength);
|
|
|
|
},
|
2020-01-31 12:08:33 +00:00
|
|
|
hasDiffFiles() {
|
|
|
|
return isNumber(this.diffFilesLength) && this.diffFilesLength >= 0;
|
|
|
|
},
|
2019-01-30 03:21:26 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="diff-stats"
|
|
|
|
:class="{
|
|
|
|
'is-compare-versions-header d-none d-lg-inline-flex': isCompareVersionsHeader,
|
|
|
|
'd-inline-flex': !isCompareVersionsHeader,
|
|
|
|
}"
|
|
|
|
>
|
2020-01-31 12:08:33 +00:00
|
|
|
<div v-if="hasDiffFiles" class="diff-stats-group">
|
2020-01-21 21:08:54 +00:00
|
|
|
<icon name="doc-code" class="diff-stats-icon text-secondary" />
|
2020-02-05 09:08:43 +00:00
|
|
|
<span class="text-secondary bold">{{ diffFilesLength }} {{ filesText }}</span>
|
2019-01-30 03:21:26 +00:00
|
|
|
</div>
|
2020-02-05 09:08:43 +00:00
|
|
|
<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-01-30 03:21:26 +00:00
|
|
|
</div>
|
2020-02-05 09:08:43 +00:00
|
|
|
<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-01-30 03:21:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|