1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-18 08:04:25 +00:00

Fix Activity Page Contributors dropdown (#31264)

Fix #31261
This commit is contained in:
wxiaoguang 2024-06-06 10:28:33 +08:00 committed by GitHub
parent 06ebae7472
commit e728fd741b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 17 deletions

View File

@ -19,14 +19,8 @@ const (
// Contributors render the page to show repository contributors graph // Contributors render the page to show repository contributors graph
func Contributors(ctx *context.Context) { func Contributors(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.contributors") ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.contributors")
ctx.Data["PageIsActivity"] = true ctx.Data["PageIsActivity"] = true
ctx.Data["PageIsContributors"] = true ctx.Data["PageIsContributors"] = true
ctx.PageData["contributionType"] = "commits"
ctx.PageData["repoLink"] = ctx.Repo.RepoLink
ctx.HTML(http.StatusOK, tplContributors) ctx.HTML(http.StatusOK, tplContributors)
} }

View File

@ -1,5 +1,6 @@
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}} {{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
<div id="repo-contributors-chart" <div id="repo-contributors-chart"
data-repo-link="{{.RepoLink}}"
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"}}"

View File

@ -23,8 +23,6 @@ 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';
const {pageData} = window.config;
const customEventListener = { const customEventListener = {
id: 'customEventListener', id: 'customEventListener',
afterEvent: (chart, args, opts) => { afterEvent: (chart, args, opts) => {
@ -59,14 +57,17 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
repoLink: {
type: String,
required: true,
},
}, },
data: () => ({ data: () => ({
isLoading: false, isLoading: false,
errorText: '', errorText: '',
totalStats: {}, totalStats: {},
sortedContributors: {}, sortedContributors: {},
repoLink: pageData.repoLink || [], type: 'commits',
type: pageData.contributionType,
contributorsStats: [], contributorsStats: [],
xAxisStart: null, xAxisStart: null,
xAxisEnd: null, xAxisEnd: null,
@ -333,19 +334,17 @@ export default {
<!-- Contribution type --> <!-- Contribution type -->
<div class="ui dropdown jump" id="repo-contributors"> <div class="ui dropdown jump" id="repo-contributors">
<div class="ui basic compact button"> <div class="ui basic compact button">
<span class="text"> <span class="not-mobile">{{ locale.filterLabel }}</span> <strong>{{ locale.contributionType[type] }}</strong>
<span class="not-mobile">{{ locale.filterLabel }}&nbsp;</span><strong>{{ locale.contributionType[type] }}</strong>
<svg-icon name="octicon-triangle-down" :size="14"/> <svg-icon name="octicon-triangle-down" :size="14"/>
</span>
</div> </div>
<div class="menu"> <div class="menu">
<div :class="['item', {'active': type === 'commits'}]"> <div :class="['item', {'selected': type === 'commits'}]" data-value="commits">
{{ locale.contributionType.commits }} {{ locale.contributionType.commits }}
</div> </div>
<div :class="['item', {'active': type === 'additions'}]"> <div :class="['item', {'selected': type === 'additions'}]" data-value="additions">
{{ locale.contributionType.additions }} {{ locale.contributionType.additions }}
</div> </div>
<div :class="['item', {'active': type === 'deletions'}]"> <div :class="['item', {'selected': type === 'deletions'}]" data-value="deletions">
{{ locale.contributionType.deletions }} {{ locale.contributionType.deletions }}
</div> </div>
</div> </div>

View File

@ -7,6 +7,7 @@ export async function initRepoContributors() {
const {default: RepoContributors} = await import(/* webpackChunkName: "contributors-graph" */'../components/RepoContributors.vue'); const {default: RepoContributors} = await import(/* webpackChunkName: "contributors-graph" */'../components/RepoContributors.vue');
try { try {
const View = createApp(RepoContributors, { const View = createApp(RepoContributors, {
repoLink: el.getAttribute('data-repo-link'),
locale: { locale: {
filterLabel: el.getAttribute('data-locale-filter-label'), filterLabel: el.getAttribute('data-locale-filter-label'),
contributionType: { contributionType: {