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
Minor fixes
  • Loading branch information
davidsvantesson committed Jan 12, 2020
commit 157393c20f09714b67fbfbb5f09592e5bd2f4514
16 changes: 0 additions & 16 deletions models/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,6 @@ 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
3 changes: 3 additions & 0 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ func (u *User) GetRepositories(page, pageSize int) (err error) {
}

// GetRepositoryIDs returns repositories IDs where user owned and has unittypes
// Caller shall check that units is not globally disabled
func (u *User) GetRepositoryIDs(units ...UnitType) ([]int64, error) {
var ids []int64

Expand All @@ -635,6 +636,7 @@ func (u *User) GetRepositoryIDs(units ...UnitType) ([]int64, error) {
}

// GetOrgRepositoryIDs returns repositories IDs where user's team owned and has unittypes
// Caller shall check that units is not globally disabled
func (u *User) GetOrgRepositoryIDs(units ...UnitType) ([]int64, error) {
var ids []int64

Expand All @@ -654,6 +656,7 @@ func (u *User) GetOrgRepositoryIDs(units ...UnitType) ([]int64, error) {
}

// GetAccessRepoIDs returns all repositories IDs where user's or user is a team member organizations
// Caller shall check that units is not globally disabled
func (u *User) GetAccessRepoIDs(units ...UnitType) ([]int64, error) {
ids, err := u.GetRepositoryIDs(units...)
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions routers/user/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ func Dashboard(ctx *context.Context) {

// Milestones render the user milestones page
func Milestones(ctx *context.Context) {
if models.UnitTypeIssues.UnitGlobalDisabled() && models.UnitTypePullRequests.UnitGlobalDisabled() {
log.Debug("Milestones overview page not available as both issues and pull requests are globally disabled")
ctx.Status(404)
return
}

ctx.Data["Title"] = ctx.Tr("milestones")
ctx.Data["PageIsMilestonesDashboard"] = true

Expand Down Expand Up @@ -347,7 +353,7 @@ func Issues(ctx *context.Context) {
isPullList := ctx.Params(":type") == "pulls"
if isPullList {
if models.UnitTypePullRequests.UnitGlobalDisabled() {
log.Debug("Pull request overview page not available due to unit global disabled.")
log.Debug("Pull request overview page not available as it is globally disabled.")
ctx.Status(404)
return
}
Expand All @@ -356,7 +362,7 @@ func Issues(ctx *context.Context) {
ctx.Data["PageIsPulls"] = true
} else {
if models.UnitTypeIssues.UnitGlobalDisabled() {
log.Debug("Issues overview page not available due go unit global disabled.")
log.Debug("Issues overview page not available as it is globally disabled.")
ctx.Status(404)
return
}
Expand Down
2 changes: 1 addition & 1 deletion templates/base/head_navbar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{if not .UnitPullsGlobalDisabled}}
<a class="item {{if .PageIsPulls}}active{{end}}" href="{{AppSubUrl}}/pulls">{{.i18n.Tr "pull_requests"}}</a>
{{end}}
{{if not .UnitIssuesGlobalDisabled}}
{{if not (and .UnitIssuesGlobalDisabled .UnitPullsGlobalDisabled)}}
{{if .ShowMilestonesDashboardPage}}<a class="item {{if .PageIsMilestonesDashboard}}active{{end}}" href="{{AppSubUrl}}/milestones">{{.i18n.Tr "milestones"}}</a>{{end}}
{{end}}
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "explore"}}</a>
Expand Down