Skip to content

Commit

Permalink
Allow disable code tab (#20805)
Browse files Browse the repository at this point in the history
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 <dev.lh@web.de>
  • Loading branch information
lunny and delvh authored Dec 12, 2022
1 parent 3e8285b commit 003b4e2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions routers/web/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ func SettingsPost(ctx *context.Context) {
repoChanged = true
}

if form.EnableCode && !unit_model.TypeCode.UnitGlobalDisabled() {
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
Type: unit_model.TypeCode,
})
} else if !unit_model.TypeCode.UnitGlobalDisabled() {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode)
}

if form.EnableWiki && form.EnableExternalWiki && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
if !validation.IsValidExternalURL(form.ExternalWikiURL) {
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
Expand Down
1 change: 1 addition & 0 deletions services/forms/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type RepoSettingForm struct {
EnablePrune bool

// Advanced settings
EnableCode bool
EnableWiki bool
EnableExternalWiki bool
ExternalWikiURL string
Expand Down
13 changes: 13 additions & 0 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,19 @@
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="advanced">

{{$isCodeEnabled := .Repository.UnitEnabled $.Context $.UnitTypeCode}}
<div class="inline field">
<label>{{.locale.Tr "repo.code"}}</label>
{{if .UnitTypeCode.UnitGlobalDisabled}}
<div class="ui checkbox tooltip disabled" data-content="{{.locale.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui checkbox">
{{end}}
<input class="enable-system" name="enable_code" type="checkbox"{{if $isCodeEnabled}} checked{{end}}>
<label>{{.locale.Tr "repo.code.desc"}}</label>
</div>
</div>

{{$isWikiEnabled := or (.Repository.UnitEnabled $.Context $.UnitTypeWiki) (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}}
<div class="inline field">
<label>{{.locale.Tr "repo.wiki"}}</label>
Expand Down

1 comment on commit 003b4e2

@zhangwdsad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

Please sign in to comment.