From f5c2d3197d3cbe59623214158fff6df47e9405dc Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 19 Jun 2025 16:34:46 -0700 Subject: [PATCH 1/6] Forks repository list page follow other repositories page --- routers/web/repo/view.go | 4 ++-- templates/admin/user/view.tmpl | 2 +- templates/explore/repos.tmpl | 4 ++-- templates/org/home.tmpl | 4 ++-- templates/repo/forks.tmpl | 12 ++---------- .../repo_list.tmpl => shared/repo/list.tmpl} | 2 +- .../shared/{repo_search.tmpl => repo/search.tmpl} | 0 .../notification/notification_subscriptions.tmpl | 4 ++-- templates/user/profile.tmpl | 8 ++++---- 9 files changed, 16 insertions(+), 24 deletions(-) rename templates/{explore/repo_list.tmpl => shared/repo/list.tmpl} (97%) rename templates/shared/{repo_search.tmpl => repo/search.tmpl} (100%) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 68fa17bf07f10..e331334a5c699 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -394,9 +394,9 @@ func Forks(ctx *context.Context) { } pager := context.NewPagination(int(total), pageSize, page, 5) + ctx.Data["IsForksPage"] = true ctx.Data["Page"] = pager - - ctx.Data["Forks"] = forks + ctx.Data["Repos"] = forks ctx.HTML(http.StatusOK, tplForks) } diff --git a/templates/admin/user/view.tmpl b/templates/admin/user/view.tmpl index 31616ffbf969a..67f9148e646c4 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 53742bf0d94dd..68da3983063be 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 cffdfabfaa9ab..3cde3554c94e6 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 725b67c651cb1..b8c0015d9c2be 100644 --- a/templates/repo/forks.tmpl +++ b/templates/repo/forks.tmpl @@ -5,16 +5,8 @@

{{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 97% rename from templates/explore/repo_list.tmpl rename to templates/shared/repo/list.tmpl index ad190b89b289e..104d55c6f13a0 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/shared/repo/list.tmpl @@ -7,7 +7,7 @@
- {{if and (or $.PageIsExplore $.PageIsProfileStarList) .Owner}} + {{if and (or $.IsForksPage $.PageIsExplore $.PageIsProfileStarList) .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 6ef53ab654201..e4dd27e63bf3e 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 e5c3412ddd0cf..74a53b937d1de 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}}
From 3573152386771f78d125b3daa78e5069ad389db2 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 19 Jun 2025 16:45:18 -0700 Subject: [PATCH 2/6] Fork list uses owner's avatar --- templates/shared/repo/list.tmpl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/shared/repo/list.tmpl b/templates/shared/repo/list.tmpl index 104d55c6f13a0..4827e6bdcbd15 100644 --- a/templates/shared/repo/list.tmpl +++ b/templates/shared/repo/list.tmpl @@ -2,7 +2,11 @@ {{range .Repos}}
- {{template "repo/icon" .}} + {{if $.IsForksPage}} + {{ctx.AvatarUtils.Avatar .Owner 24}} + {{else}} + {{template "repo/icon" .}} + {{end}}
From 82653ed0e81ac6fb909064adad705f25b11d574c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 20 Jun 2025 11:59:54 -0700 Subject: [PATCH 3/6] Fix test --- tests/integration/repo_fork_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/repo_fork_test.go b/tests/integration/repo_fork_test.go index db2caaf6ca0e0..bd7babd064da7 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 := ".flex-item" user1Sess := loginUser(t, "user1") user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"}) From cae834a0bd616b1e6797ea2b92bafba324ed8ea4 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 20 Jun 2025 13:01:16 -0700 Subject: [PATCH 4/6] Fix test --- tests/integration/repo_fork_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/integration/repo_fork_test.go b/tests/integration/repo_fork_test.go index bd7babd064da7..070ea27442eae 100644 --- a/tests/integration/repo_fork_test.go +++ b/tests/integration/repo_fork_test.go @@ -112,7 +112,8 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo1/forks") resp := MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - assert.Equal(t, 0, htmlDoc.Find(forkItemSelector).Length()) + // current repository will also use class "flex-item" so we need to subtract 1 + assert.Equal(t, 0, htmlDoc.Find(forkItemSelector).Length()-1) }) t.Run("Logged in", func(t *testing.T) { @@ -122,11 +123,13 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) { resp := user1Sess.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) // since user1 is an admin, he can get both of the forked repositories - assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()) + // current repository will also use class "flex-item" so we need to subtract 1 + assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()-1) assert.NoError(t, org_service.AddTeamMember(db.DefaultContext, ownerTeam2, user1)) resp = user1Sess.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) - assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()) + // current repository will also use class "flex-item" so we need to subtract 1 + assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()-1) }) } From 19c0691283b0303a1ee92a4035276926b2163e88 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 21 Jun 2025 09:26:04 -0700 Subject: [PATCH 5/6] improvements --- routers/web/explore/repo.go | 1 + routers/web/repo/view.go | 1 + routers/web/user/profile.go | 1 + templates/repo/forks.tmpl | 2 +- templates/shared/repo/list.tmpl | 2 +- tests/integration/repo_fork_test.go | 11 ++++------- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 855c2a50db42e..afa83faf18df1 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["ShowOwnerOnList"] = 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 e331334a5c699..2a01250273f5a 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -395,6 +395,7 @@ func Forks(ctx *context.Context) { pager := context.NewPagination(int(total), pageSize, page, 5) ctx.Data["IsForksPage"] = true + ctx.Data["ShowOwnerOnList"] = true ctx.Data["Page"] = pager ctx.Data["Repos"] = forks diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index f6d50cf5fe880..68c64d01c712a 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["ShowOwnerOnList"] = true repos, count, err = repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{ ListOptions: db.ListOptions{ PageSize: pagingNum, diff --git a/templates/repo/forks.tmpl b/templates/repo/forks.tmpl index b8c0015d9c2be..6e46457893eca 100644 --- a/templates/repo/forks.tmpl +++ b/templates/repo/forks.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}}
{{template "repo/header" .}} -
+

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

diff --git a/templates/shared/repo/list.tmpl b/templates/shared/repo/list.tmpl index 4827e6bdcbd15..54c5c6acf6998 100644 --- a/templates/shared/repo/list.tmpl +++ b/templates/shared/repo/list.tmpl @@ -11,7 +11,7 @@
- {{if and (or $.IsForksPage $.PageIsExplore $.PageIsProfileStarList) .Owner}} + {{if and $.ShowOwnerOnList .Owner}} {{.Owner.Name}}/ {{end}} {{.Name}} diff --git a/tests/integration/repo_fork_test.go b/tests/integration/repo_fork_test.go index 070ea27442eae..95325eefebd89 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 := ".flex-item" + forkItemSelector := ".fork-list .flex-item" user1Sess := loginUser(t, "user1") user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"}) @@ -112,8 +112,7 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo1/forks") resp := MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - // current repository will also use class "flex-item" so we need to subtract 1 - assert.Equal(t, 0, htmlDoc.Find(forkItemSelector).Length()-1) + assert.Equal(t, 0, htmlDoc.Find(forkItemSelector).Length()) }) t.Run("Logged in", func(t *testing.T) { @@ -123,13 +122,11 @@ func TestForkListLimitedAndPrivateRepos(t *testing.T) { resp := user1Sess.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) // since user1 is an admin, he can get both of the forked repositories - // current repository will also use class "flex-item" so we need to subtract 1 - assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()-1) + assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()) assert.NoError(t, org_service.AddTeamMember(db.DefaultContext, ownerTeam2, user1)) resp = user1Sess.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) - // current repository will also use class "flex-item" so we need to subtract 1 - assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()-1) + assert.Equal(t, 2, htmlDoc.Find(forkItemSelector).Length()) }) } From 37fb6798dd49b6b137429a91a161090e0982631a Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 21 Jun 2025 09:41:59 -0700 Subject: [PATCH 6/6] improvements --- routers/web/explore/repo.go | 2 +- routers/web/repo/view.go | 4 ++-- routers/web/user/profile.go | 2 +- templates/shared/repo/list.tmpl | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index afa83faf18df1..f0d7d0ce7d22b 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -151,7 +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["ShowOwnerOnList"] = 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 2a01250273f5a..f0d90f953344c 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -394,8 +394,8 @@ func Forks(ctx *context.Context) { } pager := context.NewPagination(int(total), pageSize, page, 5) - ctx.Data["IsForksPage"] = true - ctx.Data["ShowOwnerOnList"] = true + ctx.Data["ShowRepoOwnerAvatar"] = true + ctx.Data["ShowRepoOwnerOnList"] = true ctx.Data["Page"] = pager ctx.Data["Repos"] = forks diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 68c64d01c712a..d7052914b6865 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -197,7 +197,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R total = int(count) case "stars": ctx.Data["PageIsProfileStarList"] = true - ctx.Data["ShowOwnerOnList"] = true + ctx.Data["ShowRepoOwnerOnList"] = true repos, count, err = repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{ ListOptions: db.ListOptions{ PageSize: pagingNum, diff --git a/templates/shared/repo/list.tmpl b/templates/shared/repo/list.tmpl index 54c5c6acf6998..2c8af14f9c70e 100644 --- a/templates/shared/repo/list.tmpl +++ b/templates/shared/repo/list.tmpl @@ -2,7 +2,7 @@ {{range .Repos}}
- {{if $.IsForksPage}} + {{if $.ShowRepoOwnerAvatar}} {{ctx.AvatarUtils.Avatar .Owner 24}} {{else}} {{template "repo/icon" .}} @@ -11,7 +11,7 @@
- {{if and $.ShowOwnerOnList .Owner}} + {{if and $.ShowRepoOwnerOnList .Owner}} {{.Owner.Name}}/ {{end}} {{.Name}}