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

Change "show more repos" to extend the repo list #10674

Closed
wants to merge 1 commit into from
Closed
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
Change "show more repos" to extend the repo list
  • Loading branch information
lafriks committed Mar 8, 2020
commit 10446b24b23cb533ed069a8b653da8eddaae3cdc
11 changes: 7 additions & 4 deletions templates/user/dashboard/dashboard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
:search-limit="searchLimit"
:suburl="suburl"
:uid="uid"
:more-repos-link="'{{.ContextUser.HomeLink}}'"
{{if not .ContextUser.IsOrganization}}
:organizations="[
{{range .ContextUser.Orgs}}
Expand Down Expand Up @@ -81,7 +80,7 @@
</a>
</div>
</div>
<div class="ui attached table segment">
<div class="ui attached table segment repo-owner">
<ul class="repo-owner-name-list">
<li v-for="repo in repos" :class="{'private': repo.private}" v-show="showRepo(repo, reposFilter)">
<a :href="suburl + '/' + repo.full_name">
Expand All @@ -93,8 +92,12 @@
</span>
</a>
</li>
<li v-if="showMoreReposLink">
<a :href="moreReposLink">{{.i18n.Tr "home.show_more_repos"}}</a>
</ul>
</div>
<div v-if="hasMoreRepos" class="ui attached table segment">
<ul class="repo-owner-name-list">
<li>
<a @click="showMoreRepos">{{.i18n.Tr "home.show_more_repos"}}</a>
</li>
</ul>
</div>
Expand Down
21 changes: 14 additions & 7 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2795,16 +2795,13 @@ function initVueComponents() {
type: Number,
default: 0
},
moreReposLink: {
type: String,
default: ''
}
},

data() {
return {
tab: 'repos',
repos: [],
page: 1,
reposTotalCount: 0,
reposFilter: 'all',
searchQuery: '',
Expand Down Expand Up @@ -2836,13 +2833,13 @@ function initVueComponents() {
},

computed: {
showMoreReposLink() {
hasMoreRepos() {
return this.repos.length > 0 && this.repos.length < this.repoTypes[this.reposFilter].count;
},
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;
Expand All @@ -2866,6 +2863,7 @@ function initVueComponents() {
changeReposFilter(filter) {
this.reposFilter = filter;
this.repos = [];
this.page = 1;
this.repoTypes[filter].count = 0;
this.searchRepos(filter);
},
Expand Down Expand Up @@ -2896,7 +2894,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;
Expand All @@ -2910,6 +2912,11 @@ function initVueComponents() {
});
},

showMoreRepos() {
this.page += 1;
this.searchRepos(this.reposFilter);
},

repoClass(repo) {
if (repo.fork) {
return 'octicon-repo-forked';
Expand Down
5 changes: 5 additions & 0 deletions web_src/less/_dashboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@
}
}

.segment.repo-owner {
max-height: 60vh;
overflow-y: auto;
}

.repo-owner-name-list {
.item-name {
max-width: 70%;
Expand Down