]> source.dussan.org Git - gitea.git/commitdiff
Fix Activity Page Contributors dropdown (#31264) (#31269)
authorGiteabot <teabot@gitea.io>
Thu, 6 Jun 2024 08:14:00 +0000 (16:14 +0800)
committerGitHub <noreply@github.com>
Thu, 6 Jun 2024 08:14:00 +0000 (08:14 +0000)
Backport #31264 by wxiaoguang

Fix #31261

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
routers/web/repo/contributors.go
templates/repo/contributors.tmpl
web_src/js/components/RepoContributors.vue
web_src/js/features/contributors.js

index 5fda17469e9c0516579c27686a9361fc8003ab51..762fbf93795f3a6eb5371972ce8b5ef0d2791f45 100644 (file)
@@ -19,14 +19,8 @@ const (
 // Contributors render the page to show repository contributors graph
 func Contributors(ctx *context.Context) {
        ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.contributors")
-
        ctx.Data["PageIsActivity"] = true
        ctx.Data["PageIsContributors"] = true
-
-       ctx.PageData["contributionType"] = "commits"
-
-       ctx.PageData["repoLink"] = ctx.Repo.RepoLink
-
        ctx.HTML(http.StatusOK, tplContributors)
 }
 
index 54e3e426a23383fdf4805f245d56f7782b6794dd..6b8a63fe9964d53eff308ea13de5954ba88f8f9b 100644 (file)
@@ -1,5 +1,6 @@
 {{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
        <div id="repo-contributors-chart"
+               data-repo-link="{{.RepoLink}}"
                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-additions="{{ctx.Locale.Tr "repo.contributors.contribution_type.additions"}}"
index f7b05831e07b3c5f3e5ddc6737da3294e347d7a6..dec2599c0d2165386cdb75da729e64178710f0fa 100644 (file)
@@ -23,8 +23,6 @@ import {sleep} from '../utils.js';
 import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
 import $ from 'jquery';
 
-const {pageData} = window.config;
-
 const customEventListener = {
   id: 'customEventListener',
   afterEvent: (chart, args, opts) => {
@@ -59,14 +57,17 @@ export default {
       type: Object,
       required: true,
     },
+    repoLink: {
+      type: String,
+      required: true,
+    },
   },
   data: () => ({
     isLoading: false,
     errorText: '',
     totalStats: {},
     sortedContributors: {},
-    repoLink: pageData.repoLink || [],
-    type: pageData.contributionType,
+    type: 'commits',
     contributorsStats: [],
     xAxisStart: null,
     xAxisEnd: null,
@@ -333,19 +334,17 @@ export default {
         <!-- Contribution type -->
         <div class="ui dropdown jump" id="repo-contributors">
           <div class="ui basic compact button">
-            <span class="text">
-              <span class="not-mobile">{{ locale.filterLabel }}&nbsp;</span><strong>{{ locale.contributionType[type] }}</strong>
-              <svg-icon name="octicon-triangle-down" :size="14"/>
-            </span>
+            <span class="not-mobile">{{ locale.filterLabel }}</span> <strong>{{ locale.contributionType[type] }}</strong>
+            <svg-icon name="octicon-triangle-down" :size="14"/>
           </div>
           <div class="menu">
-            <div :class="['item', {'active': type === 'commits'}]">
+            <div :class="['item', {'selected': type === 'commits'}]" data-value="commits">
               {{ locale.contributionType.commits }}
             </div>
-            <div :class="['item', {'active': type === 'additions'}]">
+            <div :class="['item', {'selected': type === 'additions'}]" data-value="additions">
               {{ locale.contributionType.additions }}
             </div>
-            <div :class="['item', {'active': type === 'deletions'}]">
+            <div :class="['item', {'selected': type === 'deletions'}]" data-value="deletions">
               {{ locale.contributionType.deletions }}
             </div>
           </div>
index 1d9cba5b9bd2cf2bfba2536ef1ebf869abba9286..79b3389feea3b48752d49301e2331f598c9654bc 100644 (file)
@@ -7,6 +7,7 @@ export async function initRepoContributors() {
   const {default: RepoContributors} = await import(/* webpackChunkName: "contributors-graph" */'../components/RepoContributors.vue');
   try {
     const View = createApp(RepoContributors, {
+      repoLink: el.getAttribute('data-repo-link'),
       locale: {
         filterLabel: el.getAttribute('data-locale-filter-label'),
         contributionType: {