Skip to content

Commit 1699fc1

Browse files
Change "show more repos" to simply extend the repo list
Gitea's index page features a repository list, which by default only shows at most 15 repos. If there are more, a "show more repos" link is displayed at the bottom. Previously this was a link to the user's profile, but that is not helpful, as not all repos (e.g. those owned by organizations) are shown there.
1 parent 5749b26 commit 1699fc1

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

templates/user/dashboard/dashboard.tmpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
:search-limit="searchLimit"
2323
:suburl="suburl"
2424
:uid="uid"
25-
:more-repos-link="'{{.ContextUser.HomeLink}}'"
2625
{{if not .ContextUser.IsOrganization}}
2726
:organizations="[
2827
{{range .ContextUser.Orgs}}
@@ -94,7 +93,7 @@
9493
</a>
9594
</li>
9695
<li v-if="showMoreReposLink">
97-
<a :href="moreReposLink">{{.i18n.Tr "home.show_more_repos"}}</a>
96+
<a @click="searchMoreRepos">{{.i18n.Tr "home.show_more_repos"}}</a>
9897
</li>
9998
</ul>
10099
</div>

web_src/js/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,10 +2736,6 @@ function initVueComponents() {
27362736
organizationsTotalCount: {
27372737
type: Number,
27382738
default: 0
2739-
},
2740-
moreReposLink: {
2741-
type: String,
2742-
default: ''
27432739
}
27442740
},
27452741

@@ -2751,6 +2747,7 @@ function initVueComponents() {
27512747
reposFilter: 'all',
27522748
searchQuery: '',
27532749
isLoading: false,
2750+
page: 1,
27542751
repoTypes: {
27552752
all: {
27562753
count: 0,
@@ -2783,7 +2780,7 @@ function initVueComponents() {
27832780
searchURL() {
27842781
return `${this.suburl}/api/v1/repos/search?sort=updated&order=desc&uid=${this.uid}&q=${this.searchQuery
27852782
}&limit=${this.searchLimit}&mode=${this.repoTypes[this.reposFilter].searchMode
2786-
}${this.reposFilter !== 'all' ? '&exclusive=1' : ''}`;
2783+
}${this.reposFilter !== 'all' ? '&exclusive=1' : ''}&page=${this.page}`;
27872784
},
27882785
repoTypeCount() {
27892786
return this.repoTypes[this.reposFilter].count;
@@ -2808,6 +2805,7 @@ function initVueComponents() {
28082805
this.reposFilter = filter;
28092806
this.repos = [];
28102807
this.repoTypes[filter].count = 0;
2808+
this.page = 1;
28112809
this.searchRepos(filter);
28122810
},
28132811

@@ -2837,7 +2835,11 @@ function initVueComponents() {
28372835

28382836
$.getJSON(searchedURL, (result, _textStatus, request) => {
28392837
if (searchedURL === self.searchURL) {
2840-
self.repos = result.data;
2838+
if (self.page > 1) {
2839+
result.data.forEach(repo => self.repos.push(repo));
2840+
} else {
2841+
self.repos = result.data;
2842+
}
28412843
const count = request.getResponseHeader('X-Total-Count');
28422844
if (searchedQuery === '' && searchedMode === '') {
28432845
self.reposTotalCount = count;
@@ -2851,6 +2853,11 @@ function initVueComponents() {
28512853
});
28522854
},
28532855

2856+
searchMoreRepos() {
2857+
this.page += 1;
2858+
this.searchRepos(this.reposFilter);
2859+
},
2860+
28542861
repoClass(repo) {
28552862
if (repo.fork) {
28562863
return 'octicon octicon-repo-forked';

0 commit comments

Comments
 (0)