From ddd1e6ca833281ea1f433d9875dc41417dafaa75 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 22 Jun 2025 03:27:25 +0800 Subject: [PATCH] Forks repository list page follow other repositories page (#34784) Replace #24130 Before: ![image](https://github.com/user-attachments/assets/98c39bce-bdbf-4fc1-b476-527c5139e01f) After: ![image](https://github.com/user-attachments/assets/65fef5b8-63b9-4283-b8ea-2ac2f27cb001) --- routers/web/explore/repo.go | 1 + routers/web/repo/view.go | 5 +++-- routers/web/user/profile.go | 1 + templates/admin/user/view.tmpl | 2 +- templates/explore/repos.tmpl | 4 ++-- templates/org/home.tmpl | 4 ++-- templates/repo/forks.tmpl | 14 +++----------- .../repo_list.tmpl => shared/repo/list.tmpl} | 8 ++++++-- .../shared/{repo_search.tmpl => repo/search.tmpl} | 0 .../notification/notification_subscriptions.tmpl | 4 ++-- templates/user/profile.tmpl | 8 ++++---- tests/integration/repo_fork_test.go | 2 +- 12 files changed, 26 insertions(+), 27 deletions(-) rename templates/{explore/repo_list.tmpl => shared/repo/list.tmpl} (93%) rename templates/shared/{repo_search.tmpl => repo/search.tmpl} (100%) diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 855c2a50db..f0d7d0ce7d 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -151,6 +151,7 @@ func Repos(ctx *context.Context) { ctx.Data["CodePageIsDisabled"] = setting.Service.Explore.DisableCodePage ctx.Data["Title"] = ctx.Tr("explore") ctx.Data["PageIsExplore"] = true + ctx.Data["ShowRepoOwnerOnList"] = true ctx.Data["PageIsExploreRepositories"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 68fa17bf07..f0d90f9533 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -394,9 +394,10 @@ func Forks(ctx *context.Context) { } pager := context.NewPagination(int(total), pageSize, page, 5) + ctx.Data["ShowRepoOwnerAvatar"] = true + ctx.Data["ShowRepoOwnerOnList"] = true ctx.Data["Page"] = pager - - ctx.Data["Forks"] = forks + ctx.Data["Repos"] = forks ctx.HTML(http.StatusOK, tplForks) } diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index f6d50cf5fe..d7052914b6 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -197,6 +197,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R total = int(count) case "stars": ctx.Data["PageIsProfileStarList"] = true + ctx.Data["ShowRepoOwnerOnList"] = true repos, count, err = repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{ ListOptions: db.ListOptions{ PageSize: pagingNum, diff --git a/templates/admin/user/view.tmpl b/templates/admin/user/view.tmpl index 31616ffbf9..67f9148e64 100644 --- a/templates/admin/user/view.tmpl +++ b/templates/admin/user/view.tmpl @@ -26,7 +26,7 @@ {{ctx.Locale.Tr "admin.repositories"}} ({{ctx.Locale.Tr "admin.total" .ReposTotal}})
- {{template "explore/repo_list" .}} + {{template "shared/repo/list" .}}

{{ctx.Locale.Tr "settings.organization"}} ({{ctx.Locale.Tr "admin.total" .OrgsTotal}}) diff --git a/templates/explore/repos.tmpl b/templates/explore/repos.tmpl index 53742bf0d9..68da398306 100644 --- a/templates/explore/repos.tmpl +++ b/templates/explore/repos.tmpl @@ -2,8 +2,8 @@
{{template "explore/navbar" .}}
- {{template "shared/repo_search" .}} - {{template "explore/repo_list" .}} + {{template "shared/repo/search" .}} + {{template "shared/repo/list" .}} {{template "base/paginate" .}}
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index cffdfabfaa..3cde3554c9 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -8,8 +8,8 @@ {{if .ProfileReadmeContent}}
{{.ProfileReadmeContent}}
{{end}} - {{template "shared/repo_search" .}} - {{template "explore/repo_list" .}} + {{template "shared/repo/search" .}} + {{template "shared/repo/list" .}} {{template "base/paginate" .}} diff --git a/templates/repo/forks.tmpl b/templates/repo/forks.tmpl index 725b67c651..6e46457893 100644 --- a/templates/repo/forks.tmpl +++ b/templates/repo/forks.tmpl @@ -1,20 +1,12 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+

{{ctx.Locale.Tr "repo.forks"}}

-
- {{range .Forks}} -
- {{ctx.AvatarUtils.Avatar .Owner}} - {{.Owner.Name}} / {{.Name}} -
- {{end}} -
+ {{template "shared/repo/list" .}} + {{template "base/paginate" .}}
- - {{template "base/paginate" .}}
{{template "base/footer" .}} diff --git a/templates/explore/repo_list.tmpl b/templates/shared/repo/list.tmpl similarity index 93% rename from templates/explore/repo_list.tmpl rename to templates/shared/repo/list.tmpl index ad190b89b2..2c8af14f9c 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/shared/repo/list.tmpl @@ -2,12 +2,16 @@ {{range .Repos}}
- {{template "repo/icon" .}} + {{if $.ShowRepoOwnerAvatar}} + {{ctx.AvatarUtils.Avatar .Owner 24}} + {{else}} + {{template "repo/icon" .}} + {{end}}
- {{if and (or $.PageIsExplore $.PageIsProfileStarList) .Owner}} + {{if and $.ShowRepoOwnerOnList .Owner}} {{.Owner.Name}}/ {{end}} {{.Name}} diff --git a/templates/shared/repo_search.tmpl b/templates/shared/repo/search.tmpl similarity index 100% rename from templates/shared/repo_search.tmpl rename to templates/shared/repo/search.tmpl diff --git a/templates/user/notification/notification_subscriptions.tmpl b/templates/user/notification/notification_subscriptions.tmpl index 6ef53ab654..e4dd27e63b 100644 --- a/templates/user/notification/notification_subscriptions.tmpl +++ b/templates/user/notification/notification_subscriptions.tmpl @@ -69,8 +69,8 @@ {{template "shared/issuelist" dict "." . "listType" "dashboard"}} {{end}} {{else}} - {{template "shared/repo_search" .}} - {{template "explore/repo_list" .}} + {{template "shared/repo/search" .}} + {{template "shared/repo/list" .}} {{template "base/paginate" .}} {{end}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index e5c3412ddd..74a53b937d 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -17,8 +17,8 @@ {{template "user/dashboard/feeds" .}} {{else if eq .TabName "stars"}}
- {{template "shared/repo_search" .}} - {{template "explore/repo_list" .}} + {{template "shared/repo/search" .}} + {{template "shared/repo/list" .}} {{template "base/paginate" .}}
{{else if eq .TabName "following"}} @@ -30,8 +30,8 @@ {{else if eq .TabName "organizations"}} {{template "repo/user_cards" .}} {{else}} - {{template "shared/repo_search" .}} - {{template "explore/repo_list" .}} + {{template "shared/repo/search" .}} + {{template "shared/repo/list" .}} {{template "base/paginate" .}} {{end}}
diff --git a/tests/integration/repo_fork_test.go b/tests/integration/repo_fork_test.go index db2caaf6ca..95325eefeb 100644 --- a/tests/integration/repo_fork_test.go +++ b/tests/integration/repo_fork_test.go @@ -84,7 +84,7 @@ func TestRepoForkToOrg(t *testing.T) { func TestForkListLimitedAndPrivateRepos(t *testing.T) { defer tests.PrepareTestEnv(t)() - forkItemSelector := ".repo-fork-item" + forkItemSelector := ".fork-list .flex-item" user1Sess := loginUser(t, "user1") user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})