Skip to content

Commit c8d84df

Browse files
committed
move config options Service.EnableWiki, Server.EnableWiki to Repository
Signed-off-by: Julian Picht <[email protected]>
1 parent fe8ae36 commit c8d84df

File tree

14 files changed

+35
-35
lines changed

14 files changed

+35
-35
lines changed

custom/conf/app.ini.sample

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ ACCESS_CONTROL_ALLOW_ORIGIN =
3939
USE_COMPAT_SSH_URI = false
4040
; Close issues as long as a commit on any branch marks it as fixed
4141
DEFAULT_CLOSE_ISSUES_VIA_COMMITS_IN_ANY_BRANCH = false
42+
; Set this to false to completely disable the wiki function
43+
ENABLE_WIKI = true
44+
; Set this to false to completely disable the issue function
45+
ENABLE_ISSUES = true
4246

4347
[repository.editor]
4448
; List of file extensions for which lines should be wrapped in the CodeMirror editor
@@ -424,10 +428,6 @@ SHOW_REGISTRATION_BUTTON = true
424428
; When adding a repo to a team or creating a new repo all team members will watch the
425429
; repo automatically if enabled
426430
AUTO_WATCH_NEW_REPOS = true
427-
; Set this to false to completely disable the wiki function
428-
ENABLE_WIKI = true
429-
; Set this to false to completely disable the issue function
430-
ENABLE_ISSUES = true
431431

432432
[webhook]
433433
; Hook task queue length, increase if webhook shooting starts hanging

models/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
12781278
var units = make([]RepoUnit, 0, len(DefaultRepoUnits))
12791279
for _, tp := range DefaultRepoUnits {
12801280
if tp == UnitTypeIssues {
1281-
if !setting.Service.EnableIssues {
1281+
if !setting.Repository.EnableIssues {
12821282
continue
12831283
}
12841284
units = append(units, RepoUnit{
@@ -1291,7 +1291,7 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
12911291
},
12921292
})
12931293
} else if tp == UnitTypeWiki {
1294-
if !setting.Service.EnableWiki {
1294+
if !setting.Repository.EnableWiki {
12951295
continue
12961296
}
12971297
} else if tp == UnitTypePullRequests {

modules/setting/repository.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ var (
6464
Issue struct {
6565
LockReasons []string
6666
} `ini:"repository.issue"`
67+
68+
// global feature flags
69+
EnableWiki bool
70+
EnableIssues bool
6771
}{
6872
AnsiCharset: "",
6973
ForcePrivate: false,
@@ -121,6 +125,9 @@ var (
121125
}{
122126
LockReasons: strings.Split("Too heated,Off-topic,Spam,Resolved", ","),
123127
},
128+
129+
EnableWiki: true,
130+
EnableIssues: true,
124131
}
125132
RepoRootPath string
126133
ScriptType = "bash"
@@ -147,6 +154,10 @@ func newRepository() {
147154
}
148155
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
149156

157+
// feature flags
158+
Repository.EnableIssues = sec.Key("ENABLE_ISSUES").MustBool(true)
159+
Repository.EnableWiki = sec.Key("ENABLE_WIKI").MustBool(true)
160+
150161
if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
151162
log.Fatal("Failed to map Repository settings: %v", err)
152163
} else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {

modules/setting/service.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// Service settings
14-
var Service = struct {
14+
var Service struct {
1515
DefaultOrgVisibility string
1616
DefaultOrgVisibilityMode structs.VisibleType
1717
ActiveCodeLives int
@@ -48,13 +48,6 @@ var Service = struct {
4848
EnableOpenIDSignUp bool
4949
OpenIDWhitelist []*regexp.Regexp
5050
OpenIDBlacklist []*regexp.Regexp
51-
52-
// global feature flags
53-
EnableWiki bool
54-
EnableIssues bool
55-
}{
56-
EnableWiki: true,
57-
EnableIssues: true,
5851
}
5952

6053
func newService() {
@@ -90,10 +83,6 @@ func newService() {
9083
Service.DefaultOrgVisibility = sec.Key("DEFAULT_ORG_VISIBILITY").In("public", structs.ExtractKeysFromMapString(structs.VisibilityModes))
9184
Service.DefaultOrgVisibilityMode = structs.VisibilityModes[Service.DefaultOrgVisibility]
9285

93-
// feature flags
94-
Service.EnableIssues = sec.Key("ENABLE_ISSUES").MustBool(true)
95-
Service.EnableWiki = sec.Key("ENABLE_WIKI").MustBool(true)
96-
9786
sec = Cfg.Section("openid")
9887
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
9988
Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ func mustAllowPulls(ctx *context.APIContext) {
454454
}
455455

456456
func mustEnableIssuesOrPulls(ctx *context.APIContext) {
457-
if (!setting.Service.EnableIssues || !ctx.Repo.CanRead(models.UnitTypeIssues)) &&
457+
if (!setting.Repository.EnableIssues || !ctx.Repo.CanRead(models.UnitTypeIssues)) &&
458458
!(ctx.Repo.Repository.CanEnablePulls() && ctx.Repo.CanRead(models.UnitTypePullRequests)) {
459459
if ctx.Repo.Repository.CanEnablePulls() && log.IsTrace() {
460460
if ctx.IsSigned {

routers/repo/activity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Activity(ctx *context.Context) {
4747
var err error
4848
if ctx.Data["Activity"], err = models.GetActivityStats(ctx.Repo.Repository, timeFrom,
4949
ctx.Repo.CanRead(models.UnitTypeReleases),
50-
setting.Service.EnableIssues && ctx.Repo.CanRead(models.UnitTypeIssues),
50+
setting.Repository.EnableIssues && ctx.Repo.CanRead(models.UnitTypeIssues),
5151
ctx.Repo.CanRead(models.UnitTypePullRequests),
5252
ctx.Repo.CanRead(models.UnitTypeCode)); err != nil {
5353
ctx.ServerError("GetActivityStats", err)

routers/repo/issue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func MustAllowUserComment(ctx *context.Context) {
7373

7474
// MustEnableIssues check if repository enable internal issues
7575
func MustEnableIssues(ctx *context.Context) {
76-
if !setting.Service.EnableIssues ||
76+
if !setting.Repository.EnableIssues ||
7777
(!ctx.Repo.CanRead(models.UnitTypeIssues) &&
7878
!ctx.Repo.CanRead(models.UnitTypeExternalTracker)) {
7979
ctx.NotFound("MustEnableIssues", nil)
@@ -988,7 +988,7 @@ func GetActionIssue(ctx *context.Context) *models.Issue {
988988

989989
func checkIssueRights(ctx *context.Context, issue *models.Issue) {
990990
if issue.IsPull && !ctx.Repo.CanRead(models.UnitTypePullRequests) ||
991-
!issue.IsPull && (!setting.Service.EnableIssues || !ctx.Repo.CanRead(models.UnitTypeIssues)) {
991+
!issue.IsPull && (!setting.Repository.EnableIssues || !ctx.Repo.CanRead(models.UnitTypeIssues)) {
992992
ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
993993
}
994994
}
@@ -1013,7 +1013,7 @@ func getActionIssues(ctx *context.Context) []*models.Issue {
10131013
return nil
10141014
}
10151015
// Check access rights for all issues
1016-
issueUnitEnabled := setting.Service.EnableIssues && ctx.Repo.CanRead(models.UnitTypeIssues)
1016+
issueUnitEnabled := setting.Repository.EnableIssues && ctx.Repo.CanRead(models.UnitTypeIssues)
10171017
prUnitEnabled := ctx.Repo.CanRead(models.UnitTypePullRequests)
10181018
for _, issue := range issues {
10191019
if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled {

routers/repo/issue_label_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestUpdateIssueLabel_Clear(t *testing.T) {
134134
}
135135

136136
func TestUpdateIssueLabel_Toggle(t *testing.T) {
137-
setting.Service.EnableIssues = true
137+
setting.Repository.EnableIssues = true
138138
for _, testCase := range []struct {
139139
Action string
140140
IssueIDs []int64

routers/repo/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
218218
})
219219
}
220220

221-
if form.EnableWiki && setting.Service.EnableWiki {
221+
if form.EnableWiki && setting.Repository.EnableWiki {
222222
if form.EnableExternalWiki {
223223
if !validation.IsValidExternalURL(form.ExternalWikiURL) {
224224
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
@@ -242,7 +242,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
242242
}
243243
}
244244

245-
if form.EnableIssues && setting.Service.EnableIssues {
245+
if form.EnableIssues && setting.Repository.EnableIssues {
246246
if form.EnableExternalTracker {
247247
if !validation.IsValidExternalURL(form.ExternalTrackerURL) {
248248
ctx.Flash.Error(ctx.Tr("repo.settings.external_tracker_url_error"))

routers/repo/wiki.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333

3434
// MustEnableWiki check if wiki is enabled, if external then redirect
3535
func MustEnableWiki(ctx *context.Context) {
36-
if !setting.Service.EnableWiki {
36+
if !setting.Repository.EnableWiki {
3737
ctx.NotFound("MustEnableWiki", nil)
3838
return
3939
}

routers/user/home.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func Issues(ctx *context.Context) {
308308
ctx.ServerError("GetUserRepoPermission", fmt.Errorf("[%d]%v", repoID, err))
309309
return
310310
}
311-
if !setting.Service.EnableIssues || !perm.CanRead(models.UnitTypeIssues) {
311+
if !setting.Repository.EnableIssues || !perm.CanRead(models.UnitTypeIssues) {
312312
if log.IsTrace() {
313313
log.Trace("Permission Denied: User %-v cannot read %-v of repo %-v\n"+
314314
"User in repo has Permissions: %-+v",

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 .Service.EnableIssues}}
13+
{{if .Repository.EnableIssues}}
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 .Service.EnableIssues (.Permission.CanRead $.UnitTypeIssues)}}
58+
{{if and .Repository.EnableIssues (.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 .Service.EnableIssues (.Permission.CanRead $.UnitTypeExternalTracker)}}
64+
{{if and .Repository.EnableIssues (.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 .Service.EnableWiki (or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki))}}
82+
{{if and .Repository.EnableWiki (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 .Service.EnableWiki) (not .Service.EnableIssues) (not .Repository.CanEnablePulls)}}
112+
{{if and (not .Repository.EnableWiki) (not .Repository.EnableIssues) (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 .Service.EnableWiki}}
124+
{{if .Repository.EnableWiki}}
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 .Service.EnableIssues}}
160+
{{if .Repository.EnableIssues}}
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)