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 repo-list private and total count bugs #11500

Merged
merged 7 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Ensure limited and private org public repos are displayed on "private"
Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed May 20, 2020
commit a5c39cd0efe1d04fb96b5247361c35c643affb8e
8 changes: 7 additions & 1 deletion models/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
}

if opts.OnlyPrivate {
cond = cond.And(builder.Eq{"is_private": true})
cond = cond.And(builder.Or(
builder.Eq{"is_private": true},
builder.In("owner_id", builder.Select("id").From("`user`").Where(
builder.And(
builder.Eq{"type": UserTypeOrganization},
builder.Or(builder.Eq{"visibility": structs.VisibleTypeLimited}, builder.Eq{"visibility": structs.VisibleTypePrivate}),
)))))
}

if opts.Template != util.OptionalBoolNone {
Expand Down
2 changes: 1 addition & 1 deletion templates/user/dashboard/repolist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</div>
<div class="ui attached table segment">
<ul class="repo-owner-name-list">
<li v-for="repo in repos" :class="{'private': repo.private}" v-show="showRepo(repo)">
<li v-for="repo in repos" :class="{'private': repo.private}">
<a :href="suburl + '/' + repo.full_name">
<svg :class="'svg ' + repoClass(repo)" width="16" height="16" aria-hidden="true"><use :xlink:href="'#' + repoClass(repo)" /></svg>
<strong class="text truncate item-name">${repo.full_name}</strong>
Expand Down
45 changes: 0 additions & 45 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2911,51 +2911,6 @@ function initVueComponents() {
this.searchRepos();
},

showArchivedRepo(repo) {
switch (this.archivedFilter) {
case 'both':
return true;
case 'unarchived':
return !repo.archived;
case 'archived':
return repo.archived;
default:
return !repo.archived;
}
},

showPrivateRepo(repo) {
switch (this.privateFilter) {
case 'both':
return true;
case 'public':
return !repo.private;
case 'private':
return repo.private;
default:
return true;
}
},

showFilteredRepo(repo) {
switch (this.reposFilter) {
case 'sources':
return repo.owner.id === this.uid && !repo.mirror && !repo.fork;
case 'forks':
return repo.owner.id === this.uid && !repo.mirror && repo.fork;
case 'mirrors':
return repo.mirror;
case 'collaborative':
return repo.owner.id !== this.uid && !repo.mirror;
default:
return true;
}
},

showRepo(repo) {
return this.showArchivedRepo(repo) && this.showPrivateRepo(repo) && this.showFilteredRepo(repo);
},

searchRepos() {
const self = this;

Expand Down