Skip to content

Commit c258131

Browse files
authored
not show ref-in-new-issue pop when issue was disabled (#15761)
fix #15718 Signed-off-by: a1012112796 <[email protected]>
1 parent bdc1697 commit c258131

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

templates/repo/view_file.tmpl

+9-7
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@
111111
{{end}}
112112
</tbody>
113113
</table>
114-
<div class="code-view-menu-list ui fluid popup transition hidden">
115-
<div class="ui column relaxed equal height">
116-
<div class="column">
117-
<div class="ui link list">
118-
<a class="item ref-in-new-issue" href="{{.RepoLink}}/issues/new?body={{URLJoin AppUrl .RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.issues.context.reference_issue"}}</a>
114+
{{if $.Permission.CanRead $.UnitTypeIssues}}
115+
<div class="code-view-menu-list ui fluid popup transition hidden">
116+
<div class="ui column relaxed equal height">
117+
<div class="column">
118+
<div class="ui link list">
119+
<a class="item ref-in-new-issue" href="{{.RepoLink}}/issues/new?body={{URLJoin AppUrl .RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.issues.context.reference_issue"}}</a>
120+
</div>
121+
</div>
119122
</div>
120123
</div>
121-
</div>
122-
</div>
124+
{{end}}
123125
{{end}}
124126
{{end}}
125127
</div>

web_src/js/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,10 @@ function searchRepositories() {
22082208
}
22092209

22102210
function showCodeViewMenu() {
2211+
if ($('.code-view-menu-list').length === 0) {
2212+
return;
2213+
}
2214+
22112215
// Get clicked tr
22122216
const $code_tr = $('.code-view td.lines-code.active').parent();
22132217

@@ -2873,6 +2877,11 @@ function selectRange($list, $select, $from) {
28732877

28742878
// add hashchange to permalink
28752879
const $issue = $('a.ref-in-new-issue');
2880+
2881+
if ($issue.length === 0) {
2882+
return;
2883+
}
2884+
28762885
const matched = $issue.attr('href').match(/%23L\d+$|%23L\d+-L\d+$/);
28772886
if (matched) {
28782887
$issue.attr('href', $issue.attr('href').replace($issue.attr('href').substr(matched.index), `%23L${a}-L${b}`));
@@ -2888,6 +2897,11 @@ function selectRange($list, $select, $from) {
28882897

28892898
// add hashchange to permalink
28902899
const $issue = $('a.ref-in-new-issue');
2900+
2901+
if ($issue.length === 0) {
2902+
return;
2903+
}
2904+
28912905
const matched = $issue.attr('href').match(/%23L\d+$|%23L\d+-L\d+$/);
28922906
if (matched) {
28932907
$issue.attr('href', $issue.attr('href').replace($issue.attr('href').substr(matched.index), `%23${$select.attr('rel')}`));

0 commit comments

Comments
 (0)