From 70fc47a22a0bfaef7fb16dcc8a6a2e011b10f8d4 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 21 Apr 2023 01:33:30 +0800 Subject: [PATCH] Fix unclear "Owner" concept (#24233) Some user/org pages use `Owner` variable. It's an incorrect concept since year 2016: what is a user's owner? Actually, new code is right: use `ContextUser`. This PR cleans all legacy "Owner" variables. ## Screenshots for related pages and test results All pages are as before: ### `web/org/home.go` ![image](https://user-images.githubusercontent.com/2114189/233366687-a3643025-1f78-474d-a901-deea35b72f4d.png) ### `web/user/profile.go` ![image](https://user-images.githubusercontent.com/2114189/233366812-2e5c2fbc-3f78-44e7-88c1-ec2f612c241e.png) ### `web/user/setting/profile.go` ![image](https://user-images.githubusercontent.com/2114189/233366928-7a1e52c9-b400-4379-a4be-af06a853c5fa.png) --- routers/web/org/home.go | 1 - routers/web/user/profile.go | 2 +- routers/web/user/setting/profile.go | 2 +- templates/base/head.tmpl | 10 +++--- templates/org/menu.tmpl | 4 +-- templates/user/overview/header.tmpl | 4 +-- templates/user/profile.tmpl | 56 ++++++++++++++--------------- templates/user/settings/repos.tmpl | 2 +- 8 files changed, 40 insertions(+), 41 deletions(-) diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 8c9cc8a9d8..201eefa614 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -143,7 +143,6 @@ func Home(ctx *context.Context) { return } - ctx.Data["Owner"] = org ctx.Data["Repos"] = repos ctx.Data["Total"] = count ctx.Data["MembersTotal"] = membersCount diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index b39ba58f12..367bb306b8 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -63,7 +63,7 @@ func Profile(ctx *context.Context) { ctx.Data["Title"] = ctx.ContextUser.DisplayName() ctx.Data["PageIsUserProfile"] = true - ctx.Data["Owner"] = ctx.ContextUser + ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["OpenIDs"] = openIDs ctx.Data["IsFollowing"] = isFollowing diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index f500be7632..0a8a5e6280 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -326,7 +326,7 @@ func Repos(ctx *context.Context) { ctx.Data["Repos"] = repos } - ctx.Data["Owner"] = ctxUser + ctx.Data["ContextUser"] = ctxUser pager := context.NewPagination(count, opts.PageSize, opts.Page, 5) pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index d179140b23..3932a58598 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -30,12 +30,12 @@ {{if .PageIsUserProfile}} - + - - - {{if .Owner.Description}} - + + + {{if .ContextUser.Description}} + {{end}} {{else if .Repository}} {{if .Issue}} diff --git a/templates/org/menu.tmpl b/templates/org/menu.tmpl index 39189b0c84..1bb19a0673 100644 --- a/templates/org/menu.tmpl +++ b/templates/org/menu.tmpl @@ -2,8 +2,8 @@