New setting group 'Repository access'

This commit is contained in:
David Svantesson 2019-10-26 09:22:12 +02:00
parent 5f6a7016bc
commit c4546cd90b
4 changed files with 31 additions and 15 deletions

View file

@ -62,7 +62,7 @@ type CreateTeamForm struct {
Description string `binding:"MaxSize(255)"`
Permission string
Units []models.UnitType
IncludesAllRepositories bool
RepoAccess string
}
// Validate validates the fields

View file

@ -1495,6 +1495,7 @@ team_name = Team Name
team_desc = Description
team_name_helper = Team names should be short and memorable.
team_desc_helper = Describe the purpose or role of the team.
team_access_desc = Repository access
team_permission_desc = Permission
team_unit_desc = Allow Access to Repository Sections
@ -1568,6 +1569,8 @@ teams.add_nonexistent_repo = "The repository you're trying to add does not exist
teams.add_duplicate_users = User is already a team member.
teams.repos.none = No repositories could be accessed by this team.
teams.members.none = No members on this team.
teams.specific_repositories = Specific repositories
teams.specific_repositories_helper = Members will only have access to repositories explicitly added to the team.
teams.all_repositories = All repositories
teams.all_repositories_helper = Team has access to all repositories. Note that setting this will add all existing repositories to the team.
teams.all_repositories_read_permission_desc = This team grants <strong>Read</strong> access to <strong>all repositories</strong>: members can view and clone repositories.

View file

@ -181,13 +181,14 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
ctx.Data["PageIsOrgTeams"] = true
ctx.Data["PageIsOrgTeamsNew"] = true
ctx.Data["Units"] = models.Units
var includesAllRepositories = (form.RepoAccess == "all")
t := &models.Team{
OrgID: ctx.Org.Organization.ID,
Name: form.TeamName,
Description: form.Description,
Authorize: models.ParseAccessMode(form.Permission),
IncludesAllRepositories: form.IncludesAllRepositories,
IncludesAllRepositories: includesAllRepositories,
}
if t.Authorize < models.AccessModeOwner {
@ -271,6 +272,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
isAuthChanged := false
isIncludeAllChanged := false
var includesAllRepositories = (form.RepoAccess == "all")
if !t.IsOwnerTeam() {
// Validate permission level.
auth := models.ParseAccessMode(form.Permission)
@ -281,9 +283,9 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
t.Authorize = auth
}
if t.IncludesAllRepositories != form.IncludesAllRepositories {
if t.IncludesAllRepositories != includesAllRepositories {
isIncludeAllChanged = true
t.IncludesAllRepositories = form.IncludesAllRepositories
t.IncludesAllRepositories = includesAllRepositories
}
}
t.Description = form.Description

View file

@ -24,6 +24,24 @@
<span class="help">{{.i18n.Tr "org.team_desc_helper"}}</span>
</div>
{{if not (eq .Team.LowerName "owners")}}
<div class="grouped field">
<label>{{.i18n.Tr "org.team_access_desc"}}</label>
<br>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="repo_access" value="specific" {{if not .Team.IncludesAllRepositories}}checked{{end}}>
<label>{{.i18n.Tr "org.teams.specific_repositories"}}</label>
<span class="help">{{.i18n.Tr "org.teams.specific_repositories_helper"}}</span>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="repo_access" value="all" {{if .Team.IncludesAllRepositories}}checked{{end}}>
<label>{{.i18n.Tr "org.teams.all_repositories"}}</label>
<span class="help">{{.i18n.Tr "org.teams.all_repositories_helper"}}</span>
</div>
</div>
</div>
<div class="grouped field">
<label>{{.i18n.Tr "org.team_permission_desc"}}</label>
<br>
@ -48,13 +66,6 @@
<span class="help">{{.i18n.Tr "org.teams.admin_access_helper"}}</span>
</div>
</div>
<div class="inline field">
<div class="ui checkbox">
<label for="includes_all_repositories">{{.i18n.Tr "org.teams.all_repositories"}}</label>
<input id="includes_all_repositories" name="includes_all_repositories" type="checkbox" {{if .Team.IncludesAllRepositories}}checked{{end}}>
<span class="help">{{.i18n.Tr "org.teams.all_repositories_helper"}}</span>
</div>
</div>
</div>
<div class="ui divider"></div>