mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 08:21:11 +00:00 
			
		
		
		
	Show empty repos in Admin Repository Management page (#23114)
The **Admin Repository Management** page and the **Explore Repository**
page both use the `RenderRepoSearch` function. In this function, the
`OnlyShowRelevant` search option is `true` when querying repositories
for admin page.
edf98a2dc3/routers/web/explore/repo.go (L99-L115)
Refer to
[#19361](https://github.com/go-gitea/gitea/pull/19361/files#diff-8058dfb85557010e0592d586675ec62ce406af7068e6311f39c160deac37f149R497),
the repositories with `is_empty=true` will be hidden if
`OnlyShowRelevant` is `true`.
Administrators should be able to see all repositories. So
`OnlyShowRelevant` shouldn't be set to `true` .
---------
Co-authored-by: Andrew Thornton <art27@cantab.net>
	
	
This commit is contained in:
		
					parent
					
						
							
								9eb61b77ac
							
						
					
				
			
			
				commit
				
					
						347df0cbf0
					
				
			
		
					 2 changed files with 23 additions and 21 deletions
				
			
		| 
						 | 
					@ -36,6 +36,7 @@ func Repos(ctx *context.Context) {
 | 
				
			||||||
		Private:          true,
 | 
							Private:          true,
 | 
				
			||||||
		PageSize:         setting.UI.Admin.RepoPagingNum,
 | 
							PageSize:         setting.UI.Admin.RepoPagingNum,
 | 
				
			||||||
		TplName:          tplRepos,
 | 
							TplName:          tplRepos,
 | 
				
			||||||
 | 
							OnlyShowRelevant: false,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,10 +27,13 @@ type RepoSearchOptions struct {
 | 
				
			||||||
	Private          bool
 | 
						Private          bool
 | 
				
			||||||
	Restricted       bool
 | 
						Restricted       bool
 | 
				
			||||||
	PageSize         int
 | 
						PageSize         int
 | 
				
			||||||
 | 
						OnlyShowRelevant bool
 | 
				
			||||||
	TplName          base.TplName
 | 
						TplName          base.TplName
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RenderRepoSearch render repositories search page
 | 
					// RenderRepoSearch render repositories search page
 | 
				
			||||||
 | 
					// This function is also used to render the Admin Repository Management page.
 | 
				
			||||||
 | 
					// The isAdmin param should be set to true when rendering the Admin page.
 | 
				
			||||||
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
 | 
					func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
 | 
				
			||||||
	// Sitemap index for sitemap paths
 | 
						// Sitemap index for sitemap paths
 | 
				
			||||||
	page := int(ctx.ParamsInt64("idx"))
 | 
						page := int(ctx.ParamsInt64("idx"))
 | 
				
			||||||
| 
						 | 
					@ -52,7 +55,6 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
 | 
				
			||||||
		count   int64
 | 
							count   int64
 | 
				
			||||||
		err     error
 | 
							err     error
 | 
				
			||||||
		orderBy db.SearchOrderBy
 | 
							orderBy db.SearchOrderBy
 | 
				
			||||||
		onlyShowRelevant bool
 | 
					 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx.Data["SortType"] = ctx.FormString("sort")
 | 
						ctx.Data["SortType"] = ctx.FormString("sort")
 | 
				
			||||||
| 
						 | 
					@ -84,11 +86,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
 | 
				
			||||||
		orderBy = db.SearchOrderByRecentUpdated
 | 
							orderBy = db.SearchOrderByRecentUpdated
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	keyword := ctx.FormTrim("q")
 | 
						keyword := ctx.FormTrim("q")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
 | 
						ctx.Data["OnlyShowRelevant"] = opts.OnlyShowRelevant
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	topicOnly := ctx.FormBool("topic")
 | 
						topicOnly := ctx.FormBool("topic")
 | 
				
			||||||
	ctx.Data["TopicOnly"] = topicOnly
 | 
						ctx.Data["TopicOnly"] = topicOnly
 | 
				
			||||||
| 
						 | 
					@ -111,7 +111,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
 | 
				
			||||||
		TopicOnly:          topicOnly,
 | 
							TopicOnly:          topicOnly,
 | 
				
			||||||
		Language:           language,
 | 
							Language:           language,
 | 
				
			||||||
		IncludeDescription: setting.UI.SearchRepoDescription,
 | 
							IncludeDescription: setting.UI.SearchRepoDescription,
 | 
				
			||||||
		OnlyShowRelevant:   onlyShowRelevant,
 | 
							OnlyShowRelevant:   opts.OnlyShowRelevant,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		ctx.ServerError("SearchRepository", err)
 | 
							ctx.ServerError("SearchRepository", err)
 | 
				
			||||||
| 
						 | 
					@ -162,5 +162,6 @@ func Repos(ctx *context.Context) {
 | 
				
			||||||
		OwnerID:          ownerID,
 | 
							OwnerID:          ownerID,
 | 
				
			||||||
		Private:          ctx.Doer != nil,
 | 
							Private:          ctx.Doer != nil,
 | 
				
			||||||
		TplName:          tplExploreRepos,
 | 
							TplName:          tplExploreRepos,
 | 
				
			||||||
 | 
							OnlyShowRelevant: !ctx.FormBool(relevantReposOnlyParam),
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue