mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
Add "n commits" link to contributors in contributors graph page (#32799)
Fixes Issue #29365 and inherit PR #29429 - I should extend the #29429 fork but the fork is not synced, so I created another PR. - Use `silenced` class for the link, as in #29847 --------- Co-authored-by: Ben Chang <ben_chang@htc.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
c368df39b0
commit
ad7df0f70a
3 changed files with 24 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
{{if .Permission.CanRead $.UnitTypeCode}}
|
{{if .Permission.CanRead $.UnitTypeCode}}
|
||||||
<div id="repo-contributors-chart"
|
<div id="repo-contributors-chart"
|
||||||
data-repo-link="{{.RepoLink}}"
|
data-repo-link="{{.RepoLink}}"
|
||||||
|
data-repo-default-branch-name="{{.Repository.DefaultBranch}}"
|
||||||
data-locale-filter-label="{{ctx.Locale.Tr "repo.contributors.contribution_type.filter_label"}}"
|
data-locale-filter-label="{{ctx.Locale.Tr "repo.contributors.contribution_type.filter_label"}}"
|
||||||
data-locale-contribution-type-commits="{{ctx.Locale.Tr "repo.contributors.contribution_type.commits"}}"
|
data-locale-contribution-type-commits="{{ctx.Locale.Tr "repo.contributors.contribution_type.commits"}}"
|
||||||
data-locale-contribution-type-additions="{{ctx.Locale.Tr "repo.contributors.contribution_type.additions"}}"
|
data-locale-contribution-type-additions="{{ctx.Locale.Tr "repo.contributors.contribution_type.additions"}}"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import {SvgIcon} from '../svg.js';
|
import {SvgIcon} from '../svg.js';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import {
|
import {
|
||||||
Chart,
|
Chart,
|
||||||
Title,
|
Title,
|
||||||
|
@ -22,6 +23,7 @@ import {chartJsColors} from '../utils/color.js';
|
||||||
import {sleep} from '../utils.js';
|
import {sleep} from '../utils.js';
|
||||||
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
|
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
import {pathEscapeSegments} from '../utils/url.js';
|
||||||
|
|
||||||
const customEventListener = {
|
const customEventListener = {
|
||||||
id: 'customEventListener',
|
id: 'customEventListener',
|
||||||
|
@ -61,6 +63,10 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
repoDefaultBranchName: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
@ -96,6 +102,15 @@ export default {
|
||||||
.slice(0, 100);
|
.slice(0, 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getContributorSearchQuery(contributorEmail) {
|
||||||
|
const min = dayjs(this.xAxisMin).format('YYYY-MM-DD');
|
||||||
|
const max = dayjs(this.xAxisMax).format('YYYY-MM-DD');
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
'q': `after:${min}, before:${max}, author:${contributorEmail}`,
|
||||||
|
});
|
||||||
|
return `${this.repoLink}/commits/branch/${pathEscapeSegments(this.repoDefaultBranchName)}/search?${params.toString()}`;
|
||||||
|
},
|
||||||
|
|
||||||
async fetchGraphData() {
|
async fetchGraphData() {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
try {
|
try {
|
||||||
|
@ -163,7 +178,7 @@ export default {
|
||||||
// for details.
|
// for details.
|
||||||
user.max_contribution_type += 1;
|
user.max_contribution_type += 1;
|
||||||
|
|
||||||
filteredData[key] = {...user, weeks: filteredWeeks};
|
filteredData[key] = {...user, weeks: filteredWeeks, email: key};
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredData;
|
return filteredData;
|
||||||
|
@ -376,7 +391,7 @@ export default {
|
||||||
<div class="ui top attached header tw-flex tw-flex-1">
|
<div class="ui top attached header tw-flex tw-flex-1">
|
||||||
<b class="ui right">#{{ index + 1 }}</b>
|
<b class="ui right">#{{ index + 1 }}</b>
|
||||||
<a :href="contributor.home_link">
|
<a :href="contributor.home_link">
|
||||||
<img class="ui avatar tw-align-middle" height="40" width="40" :src="contributor.avatar_link">
|
<img class="ui avatar tw-align-middle" height="40" width="40" :src="contributor.avatar_link" alt="">
|
||||||
</a>
|
</a>
|
||||||
<div class="tw-ml-2">
|
<div class="tw-ml-2">
|
||||||
<a v-if="contributor.home_link !== ''" :href="contributor.home_link"><h4>{{ contributor.name }}</h4></a>
|
<a v-if="contributor.home_link !== ''" :href="contributor.home_link"><h4>{{ contributor.name }}</h4></a>
|
||||||
|
@ -384,7 +399,11 @@ export default {
|
||||||
{{ contributor.name }}
|
{{ contributor.name }}
|
||||||
</h4>
|
</h4>
|
||||||
<p class="tw-text-12 tw-flex tw-gap-1">
|
<p class="tw-text-12 tw-flex tw-gap-1">
|
||||||
<strong v-if="contributor.total_commits">{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}</strong>
|
<strong v-if="contributor.total_commits">
|
||||||
|
<a class="silenced" :href="getContributorSearchQuery(contributor.email)">
|
||||||
|
{{ contributor.total_commits.toLocaleString() }} {{ locale.contributionType.commits }}
|
||||||
|
</a>
|
||||||
|
</strong>
|
||||||
<strong v-if="contributor.total_additions" class="text green">{{ contributor.total_additions.toLocaleString() }}++ </strong>
|
<strong v-if="contributor.total_additions" class="text green">{{ contributor.total_additions.toLocaleString() }}++ </strong>
|
||||||
<strong v-if="contributor.total_deletions" class="text red">
|
<strong v-if="contributor.total_deletions" class="text red">
|
||||||
{{ contributor.total_deletions.toLocaleString() }}--</strong>
|
{{ contributor.total_deletions.toLocaleString() }}--</strong>
|
||||||
|
|
|
@ -8,6 +8,7 @@ export async function initRepoContributors() {
|
||||||
try {
|
try {
|
||||||
const View = createApp(RepoContributors, {
|
const View = createApp(RepoContributors, {
|
||||||
repoLink: el.getAttribute('data-repo-link'),
|
repoLink: el.getAttribute('data-repo-link'),
|
||||||
|
repoDefaultBranchName: el.getAttribute('data-repo-default-branch-name'),
|
||||||
locale: {
|
locale: {
|
||||||
filterLabel: el.getAttribute('data-locale-filter-label'),
|
filterLabel: el.getAttribute('data-locale-filter-label'),
|
||||||
contributionType: {
|
contributionType: {
|
||||||
|
|
Loading…
Reference in a new issue