Skip to content

Commit 003b4e2

Browse files
lunnydelvh
andauthored
Allow disable code tab (#20805)
I know some users created a repository in an organization but just use issues and projects to handle the whole organizations issues. So that `Code` could be disabled per repository. <img width="1148" alt="image" src="https://user-images.githubusercontent.com/81045/184792075-346cb508-b620-4adb-bc9a-cba76fdcb294.png"> It could also become a wiki repository. <img width="1173" alt="image" src="https://user-images.githubusercontent.com/81045/184792324-e15c6f68-35c0-4105-ab77-83585ce53672.png"> Co-authored-by: delvh <[email protected]>
1 parent 3e8285b commit 003b4e2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

routers/web/repo/setting.go

+9
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,15 @@ func SettingsPost(ctx *context.Context) {
397397
repoChanged = true
398398
}
399399

400+
if form.EnableCode && !unit_model.TypeCode.UnitGlobalDisabled() {
401+
units = append(units, repo_model.RepoUnit{
402+
RepoID: repo.ID,
403+
Type: unit_model.TypeCode,
404+
})
405+
} else if !unit_model.TypeCode.UnitGlobalDisabled() {
406+
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode)
407+
}
408+
400409
if form.EnableWiki && form.EnableExternalWiki && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
401410
if !validation.IsValidExternalURL(form.ExternalWikiURL) {
402411
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))

services/forms/repo_form.go

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ type RepoSettingForm struct {
134134
EnablePrune bool
135135

136136
// Advanced settings
137+
EnableCode bool
137138
EnableWiki bool
138139
EnableExternalWiki bool
139140
ExternalWikiURL string

templates/repo/settings/options.tmpl

+13
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@
249249
{{.CsrfTokenHtml}}
250250
<input type="hidden" name="action" value="advanced">
251251

252+
{{$isCodeEnabled := .Repository.UnitEnabled $.Context $.UnitTypeCode}}
253+
<div class="inline field">
254+
<label>{{.locale.Tr "repo.code"}}</label>
255+
{{if .UnitTypeCode.UnitGlobalDisabled}}
256+
<div class="ui checkbox tooltip disabled" data-content="{{.locale.Tr "repo.unit_disabled"}}">
257+
{{else}}
258+
<div class="ui checkbox">
259+
{{end}}
260+
<input class="enable-system" name="enable_code" type="checkbox"{{if $isCodeEnabled}} checked{{end}}>
261+
<label>{{.locale.Tr "repo.code.desc"}}</label>
262+
</div>
263+
</div>
264+
252265
{{$isWikiEnabled := or (.Repository.UnitEnabled $.Context $.UnitTypeWiki) (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}}
253266
<div class="inline field">
254267
<label>{{.locale.Tr "repo.wiki"}}</label>

0 commit comments

Comments
 (0)