Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disable code tab #20805

Merged
merged 9 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions routers/web/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,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 @@ -135,6 +135,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 $.UnitTypeCode}}
lunny marked this conversation as resolved.
Show resolved Hide resolved
<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}}>
lunny marked this conversation as resolved.
Show resolved Hide resolved
<label>{{.locale.Tr "repo.settings.code_desc"}}</label>
</div>
</div>

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