Issue and pull request filters on organization dashboard #14052 (#14072)

This commit is contained in:
Jimmy Praet 2021-01-03 18:29:12 +01:00 committed by GitHub
parent 44ff1d6a1e
commit 9cc5a89b8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 36 deletions

View file

@ -364,9 +364,6 @@ func Issues(ctx *context.Context) {
filterMode = models.FilterModeAll filterMode = models.FilterModeAll
) )
if ctxUser.IsOrganization() {
viewType = "your_repositories"
} else {
viewType = ctx.Query("type") viewType = ctx.Query("type")
switch viewType { switch viewType {
case "assigned": case "assigned":
@ -379,7 +376,6 @@ func Issues(ctx *context.Context) {
default: default:
viewType = "your_repositories" viewType = "your_repositories"
} }
}
page := ctx.QueryInt("page") page := ctx.QueryInt("page")
if page <= 1 { if page <= 1 {
@ -453,11 +449,15 @@ func Issues(ctx *context.Context) {
case models.FilterModeAll: case models.FilterModeAll:
opts.RepoIDs = userRepoIDs opts.RepoIDs = userRepoIDs
case models.FilterModeAssign: case models.FilterModeAssign:
opts.AssigneeID = ctxUser.ID opts.AssigneeID = ctx.User.ID
case models.FilterModeCreate: case models.FilterModeCreate:
opts.PosterID = ctxUser.ID opts.PosterID = ctx.User.ID
case models.FilterModeMention: case models.FilterModeMention:
opts.MentionedID = ctxUser.ID opts.MentionedID = ctx.User.ID
}
if ctxUser.IsOrganization() {
opts.RepoIDs = userRepoIDs
} }
var forceEmpty bool var forceEmpty bool
@ -575,7 +575,7 @@ func Issues(ctx *context.Context) {
} }
userIssueStatsOpts := models.UserIssueStatsOptions{ userIssueStatsOpts := models.UserIssueStatsOptions{
UserID: ctxUser.ID, UserID: ctx.User.ID,
UserRepoIDs: userRepoIDs, UserRepoIDs: userRepoIDs,
FilterMode: filterMode, FilterMode: filterMode,
IsPull: isPullList, IsPull: isPullList,
@ -585,6 +585,9 @@ func Issues(ctx *context.Context) {
if len(repoIDs) > 0 { if len(repoIDs) > 0 {
userIssueStatsOpts.UserRepoIDs = repoIDs userIssueStatsOpts.UserRepoIDs = repoIDs
} }
if ctxUser.IsOrganization() {
userIssueStatsOpts.RepoIDs = userRepoIDs
}
userIssueStats, err := models.GetUserIssueStats(userIssueStatsOpts) userIssueStats, err := models.GetUserIssueStats(userIssueStatsOpts)
if err != nil { if err != nil {
ctx.ServerError("GetUserIssueStats User", err) ctx.ServerError("GetUserIssueStats User", err)
@ -594,7 +597,7 @@ func Issues(ctx *context.Context) {
var shownIssueStats *models.IssueStats var shownIssueStats *models.IssueStats
if !forceEmpty { if !forceEmpty {
statsOpts := models.UserIssueStatsOptions{ statsOpts := models.UserIssueStatsOptions{
UserID: ctxUser.ID, UserID: ctx.User.ID,
UserRepoIDs: userRepoIDs, UserRepoIDs: userRepoIDs,
FilterMode: filterMode, FilterMode: filterMode,
IsPull: isPullList, IsPull: isPullList,
@ -604,6 +607,8 @@ func Issues(ctx *context.Context) {
} }
if len(repoIDs) > 0 { if len(repoIDs) > 0 {
statsOpts.RepoIDs = repoIDs statsOpts.RepoIDs = repoIDs
} else if ctxUser.IsOrganization() {
statsOpts.RepoIDs = userRepoIDs
} }
shownIssueStats, err = models.GetUserIssueStats(statsOpts) shownIssueStats, err = models.GetUserIssueStats(statsOpts)
if err != nil { if err != nil {
@ -616,15 +621,19 @@ func Issues(ctx *context.Context) {
var allIssueStats *models.IssueStats var allIssueStats *models.IssueStats
if !forceEmpty { if !forceEmpty {
allIssueStats, err = models.GetUserIssueStats(models.UserIssueStatsOptions{ allIssueStatsOpts := models.UserIssueStatsOptions{
UserID: ctxUser.ID, UserID: ctx.User.ID,
UserRepoIDs: userRepoIDs, UserRepoIDs: userRepoIDs,
FilterMode: filterMode, FilterMode: filterMode,
IsPull: isPullList, IsPull: isPullList,
IsClosed: isShowClosed, IsClosed: isShowClosed,
IssueIDs: issueIDsFromSearch, IssueIDs: issueIDsFromSearch,
LabelIDs: opts.LabelIDs, LabelIDs: opts.LabelIDs,
}) }
if ctxUser.IsOrganization() {
allIssueStatsOpts.RepoIDs = userRepoIDs
}
allIssueStats, err = models.GetUserIssueStats(allIssueStatsOpts)
if err != nil { if err != nil {
ctx.ServerError("GetUserIssueStats All", err) ctx.ServerError("GetUserIssueStats All", err)
return return

View file

@ -9,7 +9,6 @@
{{.i18n.Tr "home.issues.in_your_repos"}} {{.i18n.Tr "home.issues.in_your_repos"}}
<strong class="ui right">{{CountFmt .IssueStats.YourRepositoriesCount}}</strong> <strong class="ui right">{{CountFmt .IssueStats.YourRepositoriesCount}}</strong>
</a> </a>
{{if not .ContextUser.IsOrganization}}
<a class="{{if eq .ViewType "assigned"}}ui basic blue button{{end}} item" href="{{.Link}}?type=assigned&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}"> <a class="{{if eq .ViewType "assigned"}}ui basic blue button{{end}} item" href="{{.Link}}?type=assigned&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
{{.i18n.Tr "repo.issues.filter_type.assigned_to_you"}} {{.i18n.Tr "repo.issues.filter_type.assigned_to_you"}}
<strong class="ui right">{{CountFmt .IssueStats.AssignCount}}</strong> <strong class="ui right">{{CountFmt .IssueStats.AssignCount}}</strong>
@ -22,7 +21,6 @@
{{.i18n.Tr "repo.issues.filter_type.mentioning_you"}} {{.i18n.Tr "repo.issues.filter_type.mentioning_you"}}
<strong class="ui right">{{CountFmt .IssueStats.MentionCount}}</strong> <strong class="ui right">{{CountFmt .IssueStats.MentionCount}}</strong>
</a> </a>
{{end}}
<div class="ui divider"></div> <div class="ui divider"></div>
<a class="{{if not $.RepoIDs}}ui basic blue button{{end}} repo name item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&q={{$.Keyword}}"> <a class="{{if not $.RepoIDs}}ui basic blue button{{end}} repo name item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&q={{$.Keyword}}">
<span class="text truncate">All</span> <span class="text truncate">All</span>