Skip to content

Commit 3647ab6

Browse files
committed
Fix ".Repository" in templates maps to different type on different pages
Signed-off-by: Julian Picht <[email protected]>
1 parent c8d84df commit 3647ab6

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

routers/routes/routes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ func RegisterRoutes(m *macaron.Macaron) {
253253
}
254254

255255
m.Use(user.GetNotificationCount)
256+
m.Use(func(ctx *context.Context) {
257+
ctx.Data["GlobalEnableWiki"] = setting.Repository.EnableWiki
258+
ctx.Data["GlobalEnableIssues"] = setting.Repository.EnableIssues
259+
})
256260

257261
// FIXME: not all routes need go through same middlewares.
258262
// Especially some AJAX requests, we can reduce middleware number to improve performance.

templates/base/head_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
{{if .IsSigned}}
1212
<a class="item {{if .PageIsDashboard}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "dashboard"}}</a>
13-
{{if .Repository.EnableIssues}}
13+
{{if .GlobalEnableIssues}}
1414
<a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a>
1515
{{end}}
1616
<a class="item {{if .PageIsPulls}}active{{end}}" href="{{AppSubUrl}}/pulls">{{.i18n.Tr "pull_requests"}}</a>

templates/repo/header.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
</a>
5656
{{end}}
5757

58-
{{if and .Repository.EnableIssues (.Permission.CanRead $.UnitTypeIssues)}}
58+
{{if and .GlobalEnableIssues (.Permission.CanRead $.UnitTypeIssues)}}
5959
<a class="{{if .PageIsIssueList}}active{{end}} item" href="{{.RepoLink}}/issues">
6060
<i class="octicon octicon-issue-opened"></i> {{.i18n.Tr "repo.issues"}} <span class="ui {{if not .Repository.NumOpenIssues}}gray{{else}}blue{{end}} small label">{{.Repository.NumOpenIssues}}</span>
6161
</a>
6262
{{end}}
6363

64-
{{if and .Repository.EnableIssues (.Permission.CanRead $.UnitTypeExternalTracker)}}
64+
{{if and .GlobalEnableIssues (.Permission.CanRead $.UnitTypeExternalTracker)}}
6565
<a class="{{if .PageIsIssueList}}active{{end}} item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
6666
<i class="octicon octicon-link-external"></i> {{.i18n.Tr "repo.issues"}} </span>
6767
</a>
@@ -79,7 +79,7 @@
7979
</a>
8080
{{end}}
8181

82-
{{if and .Repository.EnableWiki (or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki))}}
82+
{{if and .GlobalEnableWiki (or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki))}}
8383
<a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if (.Permission.CanRead $.UnitTypeExternalWiki)}} target="_blank" rel="noopener noreferrer" {{end}}>
8484
<i class="octicon octicon-book"></i> {{.i18n.Tr "repo.wiki"}}
8585
</a>

templates/repo/settings/options.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
{{.i18n.Tr "repo.settings.advanced_settings"}}
110110
</h4>
111111
<div class="ui attached segment">
112-
{{if and (not .Repository.EnableWiki) (not .Repository.EnableIssues) (not .Repository.CanEnablePulls)}}
112+
{{if and (not .GlobalEnableWiki) (not .GlobalEnableIssues) (not .Repository.CanEnablePulls)}}
113113
<div class="inline field">
114114
<label>{{.i18n.Tr "repo.wiki.disabled"}}</label>
115115
</div>
@@ -121,7 +121,7 @@
121121
{{.CsrfTokenHtml}}
122122
<input type="hidden" name="action" value="advanced">
123123

124-
{{if .Repository.EnableWiki}}
124+
{{if .GlobalEnableWiki}}
125125
{{$isWikiEnabled := or (.Repository.UnitEnabled $.UnitTypeWiki) (.Repository.UnitEnabled $.UnitTypeExternalWiki)}}
126126
<div class="inline field">
127127
<label>{{.i18n.Tr "repo.wiki"}}</label>
@@ -157,7 +157,7 @@
157157

158158
<div class="ui divider"></div>
159159

160-
{{if .Repository.EnableIssues}}
160+
{{if .GlobalEnableIssues}}
161161
{{$isIssuesEnabled := or (.Repository.UnitEnabled $.UnitTypeIssues) (.Repository.UnitEnabled $.UnitTypeExternalTracker)}}
162162
<div class="inline field">
163163
<label>{{.i18n.Tr "repo.issues"}}</label>

0 commit comments

Comments
 (0)