diff options
author | Chai-Shi <changchaishi@gmail.com> | 2024-12-13 03:02:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 19:02:54 +0000 |
commit | c9487a755b742fd2257f57cec1ead3f4c71174d7 (patch) | |
tree | 2f543e8af17a6394cf6b5bbf9b71f73980d2d6e7 /web_src/js | |
parent | 00e2b339b6ba2df29c0c050221e58af5e7707ef8 (diff) | |
download | gitea-c9487a755b742fd2257f57cec1ead3f4c71174d7.tar.gz gitea-c9487a755b742fd2257f57cec1ead3f4c71174d7.zip |
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>
Diffstat (limited to 'web_src/js')
-rw-r--r-- | web_src/js/components/RepoContributors.vue | 27 | ||||
-rw-r--r-- | web_src/js/features/contributors.ts | 1 |
2 files changed, 24 insertions, 4 deletions
diff --git a/web_src/js/components/RepoContributors.vue b/web_src/js/components/RepoContributors.vue index 97678b9a13..e79fc80d8e 100644 --- a/web_src/js/components/RepoContributors.vue +++ b/web_src/js/components/RepoContributors.vue @@ -1,5 +1,6 @@ <script lang="ts"> import {SvgIcon} from '../svg.ts'; +import dayjs from 'dayjs'; import { Chart, Title, @@ -26,6 +27,7 @@ import {sleep} from '../utils.ts'; import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; import {fomanticQuery} from '../modules/fomantic/base.ts'; import type {Entries} from 'type-fest'; +import {pathEscapeSegments} from '../utils/url.ts'; const customEventListener: Plugin = { id: 'customEventListener', @@ -65,6 +67,10 @@ export default { type: String, required: true, }, + repoDefaultBranchName: { + type: String, + required: true, + }, }, data: () => ({ isLoading: false, @@ -100,6 +106,15 @@ export default { .slice(0, 100); }, + getContributorSearchQuery(contributorEmail: string) { + 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() { this.isLoading = true; try { @@ -167,7 +182,7 @@ export default { // for details. user.max_contribution_type += 1; - filteredData[key] = {...user, weeks: filteredWeeks}; + filteredData[key] = {...user, weeks: filteredWeeks, email: key}; } return filteredData; @@ -215,7 +230,7 @@ export default { }; }, - updateOtherCharts({chart}: {chart: Chart}, reset?: boolean = false) { + updateOtherCharts({chart}: {chart: Chart}, reset: boolean = false) { const minVal = chart.options.scales.x.min; const maxVal = chart.options.scales.x.max; if (reset) { @@ -381,7 +396,7 @@ export default { <div class="ui top attached header tw-flex tw-flex-1"> <b class="ui right">#{{ index + 1 }}</b> <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> <div class="tw-ml-2"> <a v-if="contributor.home_link !== ''" :href="contributor.home_link"><h4>{{ contributor.name }}</h4></a> @@ -389,7 +404,11 @@ export default { {{ contributor.name }} </h4> <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_deletions" class="text red"> {{ contributor.total_deletions.toLocaleString() }}--</strong> diff --git a/web_src/js/features/contributors.ts b/web_src/js/features/contributors.ts index 475c66e900..95fc81f5b3 100644 --- a/web_src/js/features/contributors.ts +++ b/web_src/js/features/contributors.ts @@ -8,6 +8,7 @@ export async function initRepoContributors() { try { const View = createApp(RepoContributors, { repoLink: el.getAttribute('data-repo-link'), + repoDefaultBranchName: el.getAttribute('data-repo-default-branch-name'), locale: { filterLabel: el.getAttribute('data-locale-filter-label'), contributionType: { |