Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Activity Page Contributors dropdown #31264

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions routers/web/repo/contributors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
ctx.HTML(http.StatusOK, tplContributors)
}

Expand Down
1 change: 1 addition & 0 deletions templates/repo/contributors.tmpl
Original file line number Diff line number Diff line change
@@ -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"}}"
Expand Down
21 changes: 10 additions & 11 deletions web_src/js/components/RepoContributors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"/>
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class="menu">
<div :class="['item', {'active': type === 'commits'}]">
<div :class="['item', {'selected': type === 'commits'}]" data-value="commits">
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
{{ 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>
Expand Down
1 change: 1 addition & 0 deletions web_src/js/features/contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down