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

Add setting to set default and global disabled repository units. #8788

Merged
merged 16 commits into from
Jan 17, 2020
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
Prev Previous commit
Next Next commit
Hide units
  • Loading branch information
davidsvantesson committed Jan 9, 2020
commit 70b39b917ed87249703be7e1d844a82a30d6dfbf
16 changes: 16 additions & 0 deletions models/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ func (u *UnitType) CanBeDefault() bool {
return true
}

// GetContradictingUnits return units that can't be active at same time as this unit
func (u *UnitType) GetContradictingUnits() []UnitType {
switch *u {
case UnitTypeIssues:
return []UnitType{UnitTypeExternalTracker}
case UnitTypeExternalTracker:
return []UnitType{UnitTypeIssues}
case UnitTypeWiki:
return []UnitType{UnitTypeExternalWiki}
case UnitTypeExternalWiki:
return []UnitType{UnitTypeWiki}
default:
return nil
}
}

// Unit is a section of one repository
type Unit struct {
Type UnitType
Expand Down
42 changes: 21 additions & 21 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,31 @@
{{$isWikiEnabled := or (.Repository.UnitEnabled $.UnitTypeWiki) (.Repository.UnitEnabled $.UnitTypeExternalWiki)}}
<div class="inline field">
<label>{{.i18n.Tr "repo.wiki"}}</label>
{{if or (.Repository.AllowEnableInternalWiki .IsAdmin) (.Repository.AllowEnableExternalWiki .IsAdmin)}}
<div class="ui checkbox">
{{if and ($.UnitTypeWiki.UnitGlobalDisabled) ($.UnitTypeExternalWiki.UnitGlobalDisabled)}}
<div class="ui checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
<div class="ui checkbox">
{{end}}
<input class="enable-system" name="enable_wiki" type="checkbox" data-target="#wiki_box" {{if $isWikiEnabled}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.wiki_desc"}}</label>
</div>
</div>
<div class="field {{if not $isWikiEnabled}}disabled{{end}}" id="wiki_box">
<div class="field">
{{if .Repository.AllowEnableInternalWiki .IsAdmin}}
<div class="ui radio checkbox">
{{else}}
{{if $.UnitTypeWiki.UnitGlobalDisabled}}
<div class="ui radio checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui radio checkbox">
{{end}}
<input class="hidden enable-system-radio" tabindex="0" name="enable_external_wiki" type="radio" value="false" data-target="#external_wiki_box" {{if not (.Repository.UnitEnabled $.UnitTypeExternalWiki)}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.use_internal_wiki"}}</label>
</div>
</div>
<div class="field">
{{if .Repository.AllowEnableExternalWiki .IsAdmin}}
<div class="ui radio checkbox">
{{else}}
{{if $.UnitTypeWiki.UnitGlobalDisabled}}
<div class="ui radio checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui radio checkbox">
{{end}}
<input class="hidden enable-system-radio" tabindex="0" name="enable_external_wiki" type="radio" value="true" data-target="#external_wiki_box" {{if .Repository.UnitEnabled $.UnitTypeExternalWiki}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.use_external_wiki"}}</label>
Expand All @@ -186,21 +186,21 @@
{{$isIssuesEnabled := or (.Repository.UnitEnabled $.UnitTypeIssues) (.Repository.UnitEnabled $.UnitTypeExternalTracker)}}
<div class="inline field">
<label>{{.i18n.Tr "repo.issues"}}</label>
{{if or (.Repository.AllowEnableInternalIssues .IsAdmin) (.Repository.AllowEnableExternalTracker .IsAdmin)}}
<div class="ui checkbox">
{{else}}
{{if or ($.UnitTypeIssues.UnitGlobalDisabled) ($.UnitTypeExternalTracker.UnitGlobalDisabled)}}
<div class="ui checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui checkbox">
{{end}}
<input class="enable-system" name="enable_issues" type="checkbox" data-target="#issue_box" {{if $isIssuesEnabled}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.issues_desc"}}</label>
</div>
</div>
<div class="field {{if not $isIssuesEnabled}}disabled{{end}}" id="issue_box">
<div class="field">
{{if .Repository.AllowEnableInternalIssues .IsAdmin}}
<div class="ui radio checkbox">
{{else}}
{{if $.UnitTypeIssues.UnitGlobalDisabled}}
<div class="ui radio checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui radio checkbox">
{{end}}
<input class="hidden enable-system-radio" tabindex="0" name="enable_external_tracker" type="radio" value="false" data-context="#internal_issue_box" data-target="#external_issue_box" {{if not (.Repository.UnitEnabled $.UnitTypeExternalTracker)}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.use_internal_issue_tracker"}}</label>
Expand Down Expand Up @@ -229,10 +229,10 @@
</div>
</div>
<div class="field">
{{if .Repository.AllowEnableExternalTracker .IsAdmin}}
<div class="ui radio checkbox">
{{else}}
{{if $.UnitTypeExternalWiki.UnitGlobalDisabled}}
<div class="ui radio checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui radio checkbox">
{{end}}
<input class="hidden enable-system-radio" tabindex="0" name="enable_external_tracker" type="radio" value="true" data-context="#internal_issue_box" data-target="#external_issue_box" {{if .Repository.UnitEnabled $.UnitTypeExternalTracker}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.use_external_issue_tracker"}}</label>
Expand Down Expand Up @@ -275,10 +275,10 @@
{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
<div class="inline field">
<label>{{.i18n.Tr "repo.pulls"}}</label>
{{if .Repository.AllowEnablePulls .IsAdmin}}
<div class="ui checkbox">
{{else}}
{{if $.UnitTypePullRequests.UnitGlobalDisabled}}
<div class="ui checkbox poping up disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
{{else}}
<div class="ui checkbox">
{{end}}
<input class="enable-system" name="enable_pulls" type="checkbox" data-target="#pull_box" {{if $pullRequestEnabled}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
Expand Down