Fix counting and filtering on the dashboard page for issues (#26657)
This PR has multiple parts, and I didn't split them because
it's not easy to test them separately since they are all about the
dashboard page for issues.
1. Support counting issues via indexer to fix #26361
2. Fix repo selection so it also fixes #26653
3. Keep keywords in filter links.
The first two are regressions of #26012.
After:
71dfea7e
-d9e2-42b6-851a-cc081435c946
Thanks to @CaiCandong for helping with some tests.
This commit is contained in:
parent
3b91b2d6b1
commit
5db21ce7e1
5 changed files with 187 additions and 110 deletions
|
@ -130,6 +130,10 @@ type SearchRepoOptions struct {
|
|||
// True -> include just collaborative
|
||||
// False -> include just non-collaborative
|
||||
Collaborate util.OptionalBool
|
||||
// What type of unit the user can be collaborative in,
|
||||
// it is ignored if Collaborate is False.
|
||||
// TypeInvalid means any unit type.
|
||||
UnitType unit.Type
|
||||
// None -> include forks AND non-forks
|
||||
// True -> include just forks
|
||||
// False -> include just non-forks
|
||||
|
@ -382,19 +386,25 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
|
|||
|
||||
if opts.Collaborate != util.OptionalBoolFalse {
|
||||
// A Collaboration is:
|
||||
collaborateCond := builder.And(
|
||||
// 1. Repository we don't own
|
||||
builder.Neq{"owner_id": opts.OwnerID},
|
||||
// 2. But we can see because of:
|
||||
builder.Or(
|
||||
// A. We have unit independent access
|
||||
UserAccessRepoCond("`repository`.id", opts.OwnerID),
|
||||
// B. We are in a team for
|
||||
UserOrgTeamRepoCond("`repository`.id", opts.OwnerID),
|
||||
// C. Public repositories in organizations that we are member of
|
||||
userOrgPublicRepoCondPrivate(opts.OwnerID),
|
||||
),
|
||||
)
|
||||
|
||||
collaborateCond := builder.NewCond()
|
||||
// 1. Repository we don't own
|
||||
collaborateCond = collaborateCond.And(builder.Neq{"owner_id": opts.OwnerID})
|
||||
// 2. But we can see because of:
|
||||
{
|
||||
userAccessCond := builder.NewCond()
|
||||
// A. We have unit independent access
|
||||
userAccessCond = userAccessCond.Or(UserAccessRepoCond("`repository`.id", opts.OwnerID))
|
||||
// B. We are in a team for
|
||||
if opts.UnitType == unit.TypeInvalid {
|
||||
userAccessCond = userAccessCond.Or(UserOrgTeamRepoCond("`repository`.id", opts.OwnerID))
|
||||
} else {
|
||||
userAccessCond = userAccessCond.Or(userOrgTeamUnitRepoCond("`repository`.id", opts.OwnerID, opts.UnitType))
|
||||
}
|
||||
// C. Public repositories in organizations that we are member of
|
||||
userAccessCond = userAccessCond.Or(userOrgPublicRepoCondPrivate(opts.OwnerID))
|
||||
collaborateCond = collaborateCond.And(userAccessCond)
|
||||
}
|
||||
if !opts.Private {
|
||||
collaborateCond = collaborateCond.And(builder.Expr("owner_id NOT IN (SELECT org_id FROM org_user WHERE org_user.uid = ? AND org_user.is_public = ?)", opts.OwnerID, false))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue