From e1d8885a9b2f7511eb599f43f2de6e60eae7b615 Mon Sep 17 00:00:00 2001 From: Alexey Korobkov Date: Wed, 18 May 2022 17:57:21 +0300 Subject: [PATCH 01/10] Show source/target branches on PR's list --- custom/conf/app.example.ini | 3 ++ .../doc/advanced/config-cheat-sheet.en-us.md | 1 + models/issue_list.go | 23 +++++++++++---- modules/setting/setting.go | 2 ++ routers/web/repo/issue.go | 1 + routers/web/user/home.go | 2 ++ templates/shared/issuelist.tmpl | 23 +++++++++++++++ web_src/less/_base.less | 2 ++ web_src/less/helpers.less | 1 + web_src/less/shared/issuelist.less | 28 +++++++++++++++++++ web_src/less/themes/theme-arc-green.less | 2 ++ 11 files changed, 82 insertions(+), 6 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 476b30502681..6e8847a09aa7 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1135,6 +1135,9 @@ PATH = ;; Whether to enable a Service Worker to cache frontend assets ;USE_SERVICE_WORKER = false +;; Whether the source/target branches on pull requests list shown +;SHOW_BRANCHES_ON_PR_LIST = true + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;[ui.admin] diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 4c43ba7ddb9f..46807e264771 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -190,6 +190,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used. - `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page. - `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets. +- `SHOW_BRANCHES_ON_PR_LIST`: **true**: Whether the source/target branches on pull requests list shown. ### UI - Admin (`ui.admin`) diff --git a/models/issue_list.go b/models/issue_list.go index 3116b49d8afb..a06103c6812f 100644 --- a/models/issue_list.go +++ b/models/issue_list.go @@ -27,11 +27,17 @@ const ( func (issues IssueList) getRepoIDs() []int64 { repoIDs := make(map[int64]struct{}, len(issues)) for _, issue := range issues { - if issue.Repo != nil { - continue + // Check if Repo not initialized + if issue.Repo == nil { + if _, ok := repoIDs[issue.RepoID]; !ok { + repoIDs[issue.RepoID] = struct{}{} + } } - if _, ok := repoIDs[issue.RepoID]; !ok { - repoIDs[issue.RepoID] = struct{}{} + // Add Head repo for Pull Request (only if different) + if (issue.PullRequest != nil) && (issue.PullRequest.HeadRepoID != issue.RepoID) { + if _, ok := repoIDs[issue.PullRequest.HeadRepoID]; !ok { + repoIDs[issue.PullRequest.HeadRepoID] = struct{}{} + } } } return container.KeysInt64(repoIDs) @@ -66,8 +72,13 @@ func (issues IssueList) loadRepositories(e db.Engine) ([]*repo_model.Repository, } else { repoMaps[issue.RepoID] = issue.Repo } - if issue.PullRequest != nil && issue.PullRequest.BaseRepo == nil { - issue.PullRequest.BaseRepo = issue.Repo + if issue.PullRequest != nil { + if issue.PullRequest.BaseRepo == nil { + issue.PullRequest.BaseRepo = issue.Repo + } + if issue.PullRequest.HeadRepo == nil { + issue.PullRequest.HeadRepo = repoMaps[issue.PullRequest.HeadRepoID] + } } } return valuesRepository(repoMaps), nil diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 5e317b39ea28..352657126b5e 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -228,6 +228,7 @@ var ( CustomEmojisMap map[string]string `ini:"-"` SearchRepoDescription bool UseServiceWorker bool + ShowBranchesOnPrList bool Notification struct { MinTimeout time.Duration @@ -1069,6 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true) UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false) + UI.ShowBranchesOnPrList = Cfg.Section("ui").Key("SHOW_BRANCHES_ON_PR_LIST").MustBool(true) HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt")) if err != nil { diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index f50b30da1cd0..c6f9736563e3 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -390,6 +390,7 @@ func Issues(ctx *context.Context) { } ctx.Data["Title"] = ctx.Tr("repo.pulls") ctx.Data["PageIsPullList"] = true + ctx.Data["ShowBranchesOnPrList"] = setting.UI.ShowBranchesOnPrList } else { MustEnableIssues(ctx) if ctx.Written() { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 37f6b88352f7..0a33b6ba2536 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -615,6 +615,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["Issues"] = issues + ctx.Data["ShowBranchesOnPrList"] = setting.UI.ShowBranchesOnPrList + approvalCounts, err := models.IssueList(issues).GetApprovalCounts() if err != nil { ctx.ServerError("ApprovalCounts", err) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index e81855851bf0..75d3069a9fdf 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -59,6 +59,29 @@ {{else}} {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} + {{if and .IsPull $.ShowBranchesOnPrList}} +
+ +
+ {{svg "gitea-double-chevron-left" 13 }} +
+ +
+ {{end}} {{if and .Milestone (ne $.listType "milestone")}} {{svg "octicon-milestone" 14 "mr-2"}}{{.Milestone.Name}} diff --git a/web_src/less/_base.less b/web_src/less/_base.less index 5584a6c35345..b222dd6564cb 100644 --- a/web_src/less/_base.less +++ b/web_src/less/_base.less @@ -95,6 +95,8 @@ --color-info-border: #a9d5de; --color-info-bg: #f8ffff; --color-info-text: #276f86; + --color-pull-request-list-branch-bg: #e8e8e8; + --color-pull-request-arrow-svg: #00000057; /* target-based colors */ --color-body: #ffffff; --color-text-dark: #080808; diff --git a/web_src/less/helpers.less b/web_src/less/helpers.less index 0c4bf1753af3..c66d7f0aad7b 100644 --- a/web_src/less/helpers.less +++ b/web_src/less/helpers.less @@ -15,6 +15,7 @@ .f1 { flex: 1 !important; } .fw { flex-wrap: wrap !important; } .vm { vertical-align: middle !important; } +.vb { vertical-align: bottom !important; } .w-100 { width: 100% !important; } .h-100 { height: 100% !important; } diff --git a/web_src/less/shared/issuelist.less b/web_src/less/shared/issuelist.less index dfc0acfeff30..da94f07d78f2 100644 --- a/web_src/less/shared/issuelist.less +++ b/web_src/less/shared/issuelist.less @@ -127,6 +127,34 @@ } } + .branches { + display: inline-flex; + padding: 0 6px; + + .branch { + background-color: var(--color-pull-request-list-branch-bg); + border-radius: 3px; + } + + .pointer { + display: flex; + justify-content: center; + align-items: center; + padding: 0 3px; + + svg { + color: var(--color-pull-request-arrow-svg); + } + } + + .truncated-name { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 10em; + } + } + > .item + .item { border-top: 1px solid var(--color-secondary); } diff --git a/web_src/less/themes/theme-arc-green.less b/web_src/less/themes/theme-arc-green.less index 0b8d92b01ff9..c1505cd100e4 100644 --- a/web_src/less/themes/theme-arc-green.less +++ b/web_src/less/themes/theme-arc-green.less @@ -91,6 +91,8 @@ --color-info-border: #306090; --color-info-bg: #26354c; --color-info-text: #38a8e8; + --color-pull-request-list-branch-bg: var(--color-secondary); + --color-pull-request-arrow-svg: var(--color-caret); /* target-based colors */ --color-body: #383c4a; --color-box-header: #404652; From 4636437062acdac4e3dd003f6710466cec45c3c8 Mon Sep 17 00:00:00 2001 From: Alexey Korobkov Date: Wed, 18 May 2022 19:18:46 +0300 Subject: [PATCH 02/10] Fixes from PR review #19747 --- modules/setting/setting.go | 4 ++-- routers/web/repo/issue.go | 2 +- routers/web/user/home.go | 2 +- templates/shared/issuelist.tmpl | 6 +++--- web_src/less/shared/issuelist.less | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 352657126b5e..ab19d4977934 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -228,7 +228,7 @@ var ( CustomEmojisMap map[string]string `ini:"-"` SearchRepoDescription bool UseServiceWorker bool - ShowBranchesOnPrList bool + ShowBranchesOnPRList bool Notification struct { MinTimeout time.Duration @@ -1070,7 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true) UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false) - UI.ShowBranchesOnPrList = Cfg.Section("ui").Key("SHOW_BRANCHES_ON_PR_LIST").MustBool(true) + UI.ShowBranchesOnPRList = Cfg.Section("ui").Key("SHOW_BRANCHES_ON_PR_LIST").MustBool(true) HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt")) if err != nil { diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index c6f9736563e3..3ee3959f2270 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -390,7 +390,7 @@ func Issues(ctx *context.Context) { } ctx.Data["Title"] = ctx.Tr("repo.pulls") ctx.Data["PageIsPullList"] = true - ctx.Data["ShowBranchesOnPrList"] = setting.UI.ShowBranchesOnPrList + ctx.Data["ShowBranchesOnPRList"] = setting.UI.ShowBranchesOnPRList } else { MustEnableIssues(ctx) if ctx.Written() { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 0a33b6ba2536..fe3fe7fe4f2b 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -615,7 +615,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["Issues"] = issues - ctx.Data["ShowBranchesOnPrList"] = setting.UI.ShowBranchesOnPrList + ctx.Data["ShowBranchesOnPRList"] = setting.UI.ShowBranchesOnPRList approvalCounts, err := models.IssueList(issues).GetApprovalCounts() if err != nil { diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 75d3069a9fdf..a53028dc5ba6 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -59,10 +59,10 @@ {{else}} {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} - {{if and .IsPull $.ShowBranchesOnPrList}} + {{if and .IsPull $.ShowBranchesOnPRList}}
- + {{if ne .RepoID .PullRequest.HeadRepoID}}
{{.PullRequest.HeadRepo.OwnerName}}
:
{{end}} diff --git a/web_src/less/shared/issuelist.less b/web_src/less/shared/issuelist.less index da94f07d78f2..e59a6b97201f 100644 --- a/web_src/less/shared/issuelist.less +++ b/web_src/less/shared/issuelist.less @@ -134,6 +134,10 @@ .branch { background-color: var(--color-pull-request-list-branch-bg); border-radius: 3px; + + a { + font-weight: bold; + } } .pointer { From 9443f75862990f48a0b3f5db747f490fae744fea Mon Sep 17 00:00:00 2001 From: IT-AlexKor <101557941+IT-AlexKor@users.noreply.github.com> Date: Sat, 21 May 2022 11:52:58 +0300 Subject: [PATCH 03/10] Update home.go --- routers/web/user/home.go | 1 - 1 file changed, 1 deletion(-) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index f96024e59080..5a8976fa32a9 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -618,7 +618,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["ShowBranchesOnPRList"] = setting.UI.ShowBranchesOnPRList approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx) - if err != nil { ctx.ServerError("ApprovalCounts", err) return From 6076c7efdc67b8d938765ba7483e3eea50c40633 Mon Sep 17 00:00:00 2001 From: Alexey Korobkov Date: Sat, 21 May 2022 12:06:11 +0300 Subject: [PATCH 04/10] Fix lint-backend for PR #19747 --- routers/web/user/home.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 5a8976fa32a9..504b8e6aa3eb 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -618,7 +618,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["ShowBranchesOnPRList"] = setting.UI.ShowBranchesOnPRList approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx) - if err != nil { + if err != nil { ctx.ServerError("ApprovalCounts", err) return } From 7a5a933583d3069da41c8c7f48a3fabfc9a6415f Mon Sep 17 00:00:00 2001 From: Alexey Korobkov Date: Wed, 25 May 2022 10:07:01 +0300 Subject: [PATCH 05/10] PR #19747 Remove redundant on/off option from config --- custom/conf/app.example.ini | 3 --- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 - modules/setting/setting.go | 2 -- routers/web/repo/issue.go | 1 - routers/web/user/home.go | 2 -- templates/shared/issuelist.tmpl | 2 +- 6 files changed, 1 insertion(+), 10 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6e8847a09aa7..476b30502681 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1135,9 +1135,6 @@ PATH = ;; Whether to enable a Service Worker to cache frontend assets ;USE_SERVICE_WORKER = false -;; Whether the source/target branches on pull requests list shown -;SHOW_BRANCHES_ON_PR_LIST = true - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;[ui.admin] diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 46807e264771..4c43ba7ddb9f 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -190,7 +190,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used. - `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page. - `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets. -- `SHOW_BRANCHES_ON_PR_LIST`: **true**: Whether the source/target branches on pull requests list shown. ### UI - Admin (`ui.admin`) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index ab19d4977934..5e317b39ea28 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -228,7 +228,6 @@ var ( CustomEmojisMap map[string]string `ini:"-"` SearchRepoDescription bool UseServiceWorker bool - ShowBranchesOnPRList bool Notification struct { MinTimeout time.Duration @@ -1070,7 +1069,6 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true) UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false) - UI.ShowBranchesOnPRList = Cfg.Section("ui").Key("SHOW_BRANCHES_ON_PR_LIST").MustBool(true) HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt")) if err != nil { diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 8f9cdcf0a63f..079ccbf6cf96 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -390,7 +390,6 @@ func Issues(ctx *context.Context) { } ctx.Data["Title"] = ctx.Tr("repo.pulls") ctx.Data["PageIsPullList"] = true - ctx.Data["ShowBranchesOnPRList"] = setting.UI.ShowBranchesOnPRList } else { MustEnableIssues(ctx) if ctx.Written() { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 504b8e6aa3eb..2a802053fb09 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -615,8 +615,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["Issues"] = issues - ctx.Data["ShowBranchesOnPRList"] = setting.UI.ShowBranchesOnPRList - approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx) if err != nil { ctx.ServerError("ApprovalCounts", err) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 4084b99cf020..3640d905e765 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -59,7 +59,7 @@ {{else}} {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} - {{if and .IsPull $.ShowBranchesOnPRList}} + {{if and .IsPull}}
From 25196deed2698d67b61e143a3759035a2b091495 Mon Sep 17 00:00:00 2001 From: Alexey Korobkov Date: Wed, 25 May 2022 12:23:49 +0300 Subject: [PATCH 06/10] PR #19747 * Add AppSubURL to URL's * Synchronize coloring schemes * Fix SVG size --- routers/web/repo/issue.go | 1 + routers/web/user/home.go | 2 ++ templates/shared/issuelist.tmpl | 6 +++--- web_src/less/_base.less | 4 ++-- web_src/less/themes/theme-arc-green.less | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 079ccbf6cf96..f09344320dfd 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -390,6 +390,7 @@ func Issues(ctx *context.Context) { } ctx.Data["Title"] = ctx.Tr("repo.pulls") ctx.Data["PageIsPullList"] = true + ctx.Data["AppSubURL"] = setting.AppSubURL } else { MustEnableIssues(ctx) if ctx.Written() { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 2a802053fb09..86803481bad9 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -615,6 +615,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["Issues"] = issues + ctx.Data["AppSubURL"] = setting.AppSubURL + approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx) if err != nil { ctx.ServerError("ApprovalCounts", err) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 3640d905e765..12dc1e576088 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -62,7 +62,7 @@ {{if and .IsPull}}
- {{svg "gitea-double-chevron-left" 13 }} + {{svg "gitea-double-chevron-left" 14 }}
- + {{if ne .RepoID .PullRequest.HeadRepoID}}
{{.PullRequest.HeadRepo.OwnerName}}
:
{{end}} diff --git a/web_src/less/_base.less b/web_src/less/_base.less index 0cb6cf50f1fc..90f9e5cc2f73 100644 --- a/web_src/less/_base.less +++ b/web_src/less/_base.less @@ -110,8 +110,8 @@ --color-info-border: #a9d5de; --color-info-bg: #f8ffff; --color-info-text: #276f86; - --color-pull-request-list-branch-bg: #e8e8e8; - --color-pull-request-arrow-svg: #00000057; + --color-pull-request-list-branch-bg: var(--color-secondary); + --color-pull-request-arrow-svg: var(--color-secondary-dark-3); /* target-based colors */ --color-body: #ffffff; --color-text-dark: #080808; diff --git a/web_src/less/themes/theme-arc-green.less b/web_src/less/themes/theme-arc-green.less index 2149868f7b2e..767fb7e7112a 100644 --- a/web_src/less/themes/theme-arc-green.less +++ b/web_src/less/themes/theme-arc-green.less @@ -92,7 +92,7 @@ --color-info-bg: #26354c; --color-info-text: #38a8e8; --color-pull-request-list-branch-bg: var(--color-secondary); - --color-pull-request-arrow-svg: var(--color-caret); + --color-pull-request-arrow-svg: var(--color-secondary-dark-3); /* target-based colors */ --color-body: #383c4a; --color-box-header: #404652; From 0afa9dbf8c6848731c6afa2a2e6d87813f3040f8 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 25 May 2022 18:38:19 +0800 Subject: [PATCH 07/10] refactor issue list branch names * clarify getRepoIDs usage, now it also returns the repo IDs for PullRequest.HeadRepo * remove unnecessary ctx.Data["AppSubURL"], use `repo.HTMLURL` instead * use span inside a tag, instead of div * escape the branch names in URL * remove unnecessary CSS styles and variables * use character instead of SVG arrows --- models/issue_list.go | 17 +++++------------ routers/web/repo/issue.go | 1 - routers/web/user/home.go | 2 -- templates/shared/issuelist.tmpl | 20 ++++++++++---------- web_src/less/_base.less | 2 -- web_src/less/helpers.less | 1 - web_src/less/shared/issuelist.less | 17 +---------------- web_src/less/themes/theme-arc-green.less | 2 -- 8 files changed, 16 insertions(+), 46 deletions(-) diff --git a/models/issue_list.go b/models/issue_list.go index 5cc0529cfd40..31588c02a471 100644 --- a/models/issue_list.go +++ b/models/issue_list.go @@ -25,20 +25,15 @@ const ( defaultMaxInSize = 50 ) +// get the repo IDs to be loaded later, these IDs are for issue.Repo and issue.PullRequest.HeadRepo func (issues IssueList) getRepoIDs() []int64 { repoIDs := make(map[int64]struct{}, len(issues)) for _, issue := range issues { - // Check if Repo not initialized if issue.Repo == nil { - if _, ok := repoIDs[issue.RepoID]; !ok { - repoIDs[issue.RepoID] = struct{}{} - } + repoIDs[issue.RepoID] = struct{}{} } - // Add Head repo for Pull Request (only if different) - if (issue.PullRequest != nil) && (issue.PullRequest.HeadRepoID != issue.RepoID) { - if _, ok := repoIDs[issue.PullRequest.HeadRepoID]; !ok { - repoIDs[issue.PullRequest.HeadRepoID] = struct{}{} - } + if issue.PullRequest != nil && issue.PullRequest.HeadRepo == nil { + repoIDs[issue.PullRequest.HeadRepoID] = struct{}{} } } return container.KeysInt64(repoIDs) @@ -74,9 +69,7 @@ func (issues IssueList) loadRepositories(ctx context.Context) ([]*repo_model.Rep repoMaps[issue.RepoID] = issue.Repo } if issue.PullRequest != nil { - if issue.PullRequest.BaseRepo == nil { - issue.PullRequest.BaseRepo = issue.Repo - } + issue.PullRequest.BaseRepo = issue.Repo if issue.PullRequest.HeadRepo == nil { issue.PullRequest.HeadRepo = repoMaps[issue.PullRequest.HeadRepoID] } diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index f09344320dfd..079ccbf6cf96 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -390,7 +390,6 @@ func Issues(ctx *context.Context) { } ctx.Data["Title"] = ctx.Tr("repo.pulls") ctx.Data["PageIsPullList"] = true - ctx.Data["AppSubURL"] = setting.AppSubURL } else { MustEnableIssues(ctx) if ctx.Written() { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 86803481bad9..2a802053fb09 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -615,8 +615,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["Issues"] = issues - ctx.Data["AppSubURL"] = setting.AppSubURL - approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx) if err != nil { ctx.ServerError("ApprovalCounts", err) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 12dc1e576088..b2e65a1a31b8 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -59,25 +59,25 @@ {{else}} {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} - {{if and .IsPull}} + {{if and .IsPull .PullRequest.BaseRepo .PullRequest.HeadRepo}}
diff --git a/web_src/less/_base.less b/web_src/less/_base.less index 90f9e5cc2f73..461195df0180 100644 --- a/web_src/less/_base.less +++ b/web_src/less/_base.less @@ -110,8 +110,6 @@ --color-info-border: #a9d5de; --color-info-bg: #f8ffff; --color-info-text: #276f86; - --color-pull-request-list-branch-bg: var(--color-secondary); - --color-pull-request-arrow-svg: var(--color-secondary-dark-3); /* target-based colors */ --color-body: #ffffff; --color-text-dark: #080808; diff --git a/web_src/less/helpers.less b/web_src/less/helpers.less index c66d7f0aad7b..0c4bf1753af3 100644 --- a/web_src/less/helpers.less +++ b/web_src/less/helpers.less @@ -15,7 +15,6 @@ .f1 { flex: 1 !important; } .fw { flex-wrap: wrap !important; } .vm { vertical-align: middle !important; } -.vb { vertical-align: bottom !important; } .w-100 { width: 100% !important; } .h-100 { height: 100% !important; } diff --git a/web_src/less/shared/issuelist.less b/web_src/less/shared/issuelist.less index 6c8c8f2aaacc..775fc984786d 100644 --- a/web_src/less/shared/issuelist.less +++ b/web_src/less/shared/issuelist.less @@ -124,23 +124,8 @@ padding: 0 6px; .branch { - background-color: var(--color-pull-request-list-branch-bg); + background-color: var(--color-secondary); border-radius: 3px; - - a { - font-weight: bold; - } - } - - .pointer { - display: flex; - justify-content: center; - align-items: center; - padding: 0 3px; - - svg { - color: var(--color-pull-request-arrow-svg); - } } .truncated-name { diff --git a/web_src/less/themes/theme-arc-green.less b/web_src/less/themes/theme-arc-green.less index 767fb7e7112a..01150d353e31 100644 --- a/web_src/less/themes/theme-arc-green.less +++ b/web_src/less/themes/theme-arc-green.less @@ -91,8 +91,6 @@ --color-info-border: #306090; --color-info-bg: #26354c; --color-info-text: #38a8e8; - --color-pull-request-list-branch-bg: var(--color-secondary); - --color-pull-request-arrow-svg: var(--color-secondary-dark-3); /* target-based colors */ --color-body: #383c4a; --color-box-header: #404652; From d0c27d788766f5db1e96b321349e8405618fa879 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 25 May 2022 19:04:14 +0800 Subject: [PATCH 08/10] Update templates/shared/issuelist.tmpl Co-authored-by: Lauris BH --- templates/shared/issuelist.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index b2e65a1a31b8..d187e5bcbef4 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -70,7 +70,7 @@
- « {{/* or use svg arrow: {{svg "gitea-double-chevron-left" 14 "mt-2"}} */}} + «
From cb0b2dc033c1d75329ab81a334f0d9d562344d5f Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 25 May 2022 19:52:47 +0800 Subject: [PATCH 09/10] inline the span tags to remove spaces. prevent NPE if HeadRepo is nil (BaseRepo should always exist) --- templates/shared/issuelist.tmpl | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index d187e5bcbef4..79726469035e 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -59,27 +59,25 @@ {{else}} {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} - {{if and .IsPull .PullRequest.BaseRepo .PullRequest.HeadRepo}} + {{if and .IsPull}} {{end}} {{if and .Milestone (ne $.listType "milestone")}} From 866c2d8b23a6306566666cd41625801dfc327266 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 25 May 2022 19:55:36 +0800 Subject: [PATCH 10/10] oops, remove unnecessary AND op --- templates/shared/issuelist.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 79726469035e..5392365dd125 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -59,7 +59,7 @@ {{else}} {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} - {{if and .IsPull}} + {{if .IsPull}}