From 1699fc18fcdd04cdacd461a2f8f4770ad35092da Mon Sep 17 00:00:00 2001 From: Tim Niederhausen Date: Tue, 7 Jan 2020 02:41:13 +0100 Subject: [PATCH] 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. --- templates/user/dashboard/dashboard.tmpl | 3 +-- web_src/js/index.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index 27a0a76bc443b..4d4c4ce9566ac 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -22,7 +22,6 @@ :search-limit="searchLimit" :suburl="suburl" :uid="uid" - :more-repos-link="'{{.ContextUser.HomeLink}}'" {{if not .ContextUser.IsOrganization}} :organizations="[ {{range .ContextUser.Orgs}} @@ -94,7 +93,7 @@
  • - {{.i18n.Tr "home.show_more_repos"}} + {{.i18n.Tr "home.show_more_repos"}}
  • diff --git a/web_src/js/index.js b/web_src/js/index.js index b8145fa439912..d4f4a22a079df 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2736,10 +2736,6 @@ function initVueComponents() { organizationsTotalCount: { type: Number, default: 0 - }, - moreReposLink: { - type: String, - default: '' } }, @@ -2751,6 +2747,7 @@ function initVueComponents() { reposFilter: 'all', searchQuery: '', isLoading: false, + page: 1, repoTypes: { all: { count: 0, @@ -2783,7 +2780,7 @@ function initVueComponents() { searchURL() { return `${this.suburl}/api/v1/repos/search?sort=updated&order=desc&uid=${this.uid}&q=${this.searchQuery }&limit=${this.searchLimit}&mode=${this.repoTypes[this.reposFilter].searchMode - }${this.reposFilter !== 'all' ? '&exclusive=1' : ''}`; + }${this.reposFilter !== 'all' ? '&exclusive=1' : ''}&page=${this.page}`; }, repoTypeCount() { return this.repoTypes[this.reposFilter].count; @@ -2808,6 +2805,7 @@ function initVueComponents() { this.reposFilter = filter; this.repos = []; this.repoTypes[filter].count = 0; + this.page = 1; this.searchRepos(filter); }, @@ -2837,7 +2835,11 @@ function initVueComponents() { $.getJSON(searchedURL, (result, _textStatus, request) => { if (searchedURL === self.searchURL) { - self.repos = result.data; + if (self.page > 1) { + result.data.forEach(repo => self.repos.push(repo)); + } else { + self.repos = result.data; + } const count = request.getResponseHeader('X-Total-Count'); if (searchedQuery === '' && searchedMode === '') { self.reposTotalCount = count; @@ -2851,6 +2853,11 @@ function initVueComponents() { }); }, + searchMoreRepos() { + this.page += 1; + this.searchRepos(this.reposFilter); + }, + repoClass(repo) { if (repo.fork) { return 'octicon octicon-repo-forked';