Skip to content

Commit 30008fc

Browse files
hiifongwxiaoguang
andauthored
Fix bug of branch/tag selector in the issue sidebar (#32744)
Fix: #32731 --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent 0b8a894 commit 30008fc

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

models/issues/issue.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ type Issue struct {
125125
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
126126
PullRequest *PullRequest `xorm:"-"`
127127
NumComments int
128-
Ref string
129-
PinOrder int `xorm:"DEFAULT 0"`
128+
129+
// TODO: RemoveIssueRef: see "repo/issue/branch_selector_field.tmpl"
130+
Ref string
131+
132+
PinOrder int `xorm:"DEFAULT 0"`
130133

131134
DeadlineUnix timeutil.TimeStamp `xorm:"INDEX"`
132135

templates/repo/issue/branch_selector_field.tmpl

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
{{/* TODO: RemoveIssueRef: the Issue.Ref will be removed in 1.24 or 1.25 if no end user really needs it or there could be better alternative then.
2+
PR: https://github.com/go-gitea/gitea/pull/32744
3+
4+
The Issue.Ref was added by Add possibility to record branch or tag information in an issue (#780)
5+
After 8 years, this "branch selector" does nothing more than saving the branch/tag name into database and displays it.
6+
7+
There are still users using it:
8+
* @didim99: it is a really useful feature to specify a branch in which issue found.
9+
10+
Still needs to figure out:
11+
* Could the "recording branch/tag name" be replaced by other approaches?
12+
* Write the branch name in the issue title/body then it will still be displayed, eg: `[bug] (fix/ui-broken-bug) there is a bug ....`
13+
* Is "GitHub-like development sidebar (`#31899`)" good enough (or better) for your usage?
14+
*/}}
115
{{if and (not .Issue.IsPull) (not .PageIsComparePull)}}
216
<input id="ref_selector" name="ref" type="hidden" value="{{.Reference}}">
317
<div class="ui dropdown select-branch branch-selector-dropdown ellipsis-items-nowrap {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}}"
@@ -29,7 +43,7 @@
2943
{{range .Branches}}
3044
<div class="item" data-id="refs/heads/{{.}}" data-name="{{.}}" data-id-selector="#ref_selector" title="{{.}}">{{.}}</div>
3145
{{else}}
32-
<div class="item">{{ctx.Locale.Tr "no_results_found"}}</div>
46+
<div class="item disabled">{{ctx.Locale.Tr "no_results_found"}}</div>
3347
{{end}}
3448
</div>
3549
<div id="tag-list" class="scrolling menu reference-list-menu tw-hidden">
@@ -39,7 +53,7 @@
3953
{{range .Tags}}
4054
<div class="item" data-id="refs/tags/{{.}}" data-name="tags/{{.}}" data-id-selector="#ref_selector">{{.}}</div>
4155
{{else}}
42-
<div class="item">{{ctx.Locale.Tr "no_results_found"}}</div>
56+
<div class="item disabled">{{ctx.Locale.Tr "no_results_found"}}</div>
4357
{{end}}
4458
</div>
4559
</div>

templates/repo/issue/new_form.tmpl

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
</div>
4848

4949
<div class="issue-content-right ui segment">
50-
{{template "repo/issue/branch_selector_field" $}}
50+
{{template "repo/issue/branch_selector_field" $}}{{/* TODO: RemoveIssueRef: template "repo/issue/branch_selector_field" $*/}}
51+
5152
{{if .PageIsComparePull}}
5253
{{template "repo/issue/sidebar/reviewer_list" $.IssuePageMetaData}}
5354
<div class="divider"></div>

templates/repo/issue/view_content/sidebar.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="issue-content-right ui segment">
2-
{{template "repo/issue/branch_selector_field" $}}
2+
{{template "repo/issue/branch_selector_field" $}}{{/* TODO: RemoveIssueRef: template "repo/issue/branch_selector_field" $*/}}
33

44
{{if .Issue.IsPull}}
55
{{template "repo/issue/sidebar/reviewer_list" $.IssuePageMetaData}}

templates/shared/issuelist.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<span class="gt-ellipsis">{{.Project.Title}}</span>
100100
</a>
101101
{{end}}
102-
{{if .Ref}}
102+
{{if .Ref}}{{/* TODO: RemoveIssueRef: see "repo/issue/branch_selector_field.tmpl" */}}
103103
<a class="ref flex-text-inline tw-max-w-[300px]" {{if $.RepoLink}}href="{{index $.IssueRefURLs .ID}}"{{else}}href="{{.Repo.Link}}{{index $.IssueRefURLs .ID}}"{{end}}>
104104
{{svg "octicon-git-branch" 14}}
105105
<span class="gt-ellipsis">{{index $.IssueRefEndNames .ID}}</span>

web_src/js/features/repo-issue-sidebar.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {queryElems, toggleElem} from '../utils/dom.ts';
44
import {initIssueSidebarComboList} from './repo-issue-sidebar-combolist.ts';
55

66
function initBranchSelector() {
7+
// TODO: RemoveIssueRef: see "repo/issue/branch_selector_field.tmpl"
78
const elSelectBranch = document.querySelector('.ui.dropdown.select-branch');
89
if (!elSelectBranch) return;
910

0 commit comments

Comments
 (0)