Skip to content

Commit 717b313

Browse files
6543a1012112796
andauthored
not show ref-in-new-issue pop when issue was disabled (#15761) (#15765)
fix #15718 Signed-off-by: a1012112796 <[email protected]> Co-authored-by: a1012112796 <[email protected]>
1 parent 0a32861 commit 717b313

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

templates/repo/view_file.tmpl

Lines changed: 9 additions & 7 deletions
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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,10 @@ function searchRepositories() {
21802180
}
21812181

21822182
function showCodeViewMenu() {
2183+
if ($('.code-view-menu-list').length === 0) {
2184+
return;
2185+
}
2186+
21832187
// Get clicked tr
21842188
const $code_tr = $('.code-view td.lines-code.active').parent();
21852189

@@ -2834,6 +2838,11 @@ function selectRange($list, $select, $from) {
28342838

28352839
// add hashchange to permalink
28362840
const $issue = $('a.ref-in-new-issue');
2841+
2842+
if ($issue.length === 0) {
2843+
return;
2844+
}
2845+
28372846
const matched = $issue.attr('href').match(/%23L\d+$|%23L\d+-L\d+$/);
28382847
if (matched) {
28392848
$issue.attr('href', $issue.attr('href').replace($issue.attr('href').substr(matched.index), `%23L${a}-L${b}`));
@@ -2849,6 +2858,11 @@ function selectRange($list, $select, $from) {
28492858

28502859
// add hashchange to permalink
28512860
const $issue = $('a.ref-in-new-issue');
2861+
2862+
if ($issue.length === 0) {
2863+
return;
2864+
}
2865+
28522866
const matched = $issue.attr('href').match(/%23L\d+$|%23L\d+-L\d+$/);
28532867
if (matched) {
28542868
$issue.attr('href', $issue.attr('href').replace($issue.attr('href').substr(matched.index), `%23${$select.attr('rel')}`));

0 commit comments

Comments
 (0)