2019-09-30 21:07:59 +05:30
|
|
|
<script>
|
|
|
|
import { sprintf, __ } from '~/locale';
|
|
|
|
import { MAX_COMMIT_COUNT } from '../constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import GraphBar from './graph_bar.vue';
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GraphBar,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
defaultBranch: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
distance: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
aheadCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
behindCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
maxCommits: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
title() {
|
|
|
|
if (this.distance) {
|
|
|
|
return sprintf(
|
|
|
|
__('More than %{number_commits_distance} commits different with %{default_branch}'),
|
|
|
|
{
|
|
|
|
number_commits_distance:
|
|
|
|
this.distance >= MAX_COMMIT_COUNT ? `${MAX_COMMIT_COUNT - 1}+` : this.distance,
|
|
|
|
default_branch: this.defaultBranch,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sprintf(
|
|
|
|
__(
|
|
|
|
'%{number_commits_behind} commits behind %{default_branch}, %{number_commits_ahead} commits ahead',
|
|
|
|
),
|
|
|
|
{
|
|
|
|
number_commits_behind: this.behindCount,
|
|
|
|
number_commits_ahead: this.aheadCount,
|
|
|
|
default_branch: this.defaultBranch,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div :title="title" class="divergence-graph px-2 d-none d-md-block">
|
|
|
|
<template v-if="distance">
|
|
|
|
<graph-bar :count="distance" :max-commits="maxCommits" position="full" />
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<graph-bar :count="behindCount" :max-commits="maxCommits" position="left" />
|
2020-10-24 23:57:45 +05:30
|
|
|
<div class="graph-separator float-left mt-1"></div>
|
2019-09-30 21:07:59 +05:30
|
|
|
<graph-bar :count="aheadCount" :max-commits="maxCommits" position="right" />
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|