Browse Source

New setting group 'Repository access'

pull/8688/head
David Svantesson 4 years ago
parent
commit
c4546cd90b
4 changed files with 31 additions and 15 deletions
  1. 5
    5
      modules/auth/org.go
  2. 3
    0
      options/locale/locale_en-US.ini
  3. 5
    3
      routers/org/teams.go
  4. 18
    7
      templates/org/team/new.tmpl

+ 5
- 5
modules/auth/org.go View File



// CreateTeamForm form for creating team // CreateTeamForm form for creating team
type CreateTeamForm struct { type CreateTeamForm struct {
TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `binding:"MaxSize(255)"`
Permission string
Units []models.UnitType
IncludesAllRepositories bool
TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `binding:"MaxSize(255)"`
Permission string
Units []models.UnitType
RepoAccess string
} }


// Validate validates the fields // Validate validates the fields

+ 3
- 0
options/locale/locale_en-US.ini View File

team_desc = Description team_desc = Description
team_name_helper = Team names should be short and memorable. team_name_helper = Team names should be short and memorable.
team_desc_helper = Describe the purpose or role of the team. team_desc_helper = Describe the purpose or role of the team.
team_access_desc = Repository access
team_permission_desc = Permission team_permission_desc = Permission
team_unit_desc = Allow Access to Repository Sections team_unit_desc = Allow Access to Repository Sections


teams.add_duplicate_users = User is already a team member. teams.add_duplicate_users = User is already a team member.
teams.repos.none = No repositories could be accessed by this team. teams.repos.none = No repositories could be accessed by this team.
teams.members.none = No members on 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 = 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_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. teams.all_repositories_read_permission_desc = This team grants <strong>Read</strong> access to <strong>all repositories</strong>: members can view and clone repositories.

+ 5
- 3
routers/org/teams.go View File

ctx.Data["PageIsOrgTeams"] = true ctx.Data["PageIsOrgTeams"] = true
ctx.Data["PageIsOrgTeamsNew"] = true ctx.Data["PageIsOrgTeamsNew"] = true
ctx.Data["Units"] = models.Units ctx.Data["Units"] = models.Units
var includesAllRepositories = (form.RepoAccess == "all")


t := &models.Team{ t := &models.Team{
OrgID: ctx.Org.Organization.ID, OrgID: ctx.Org.Organization.ID,
Name: form.TeamName, Name: form.TeamName,
Description: form.Description, Description: form.Description,
Authorize: models.ParseAccessMode(form.Permission), Authorize: models.ParseAccessMode(form.Permission),
IncludesAllRepositories: form.IncludesAllRepositories,
IncludesAllRepositories: includesAllRepositories,
} }


if t.Authorize < models.AccessModeOwner { if t.Authorize < models.AccessModeOwner {


isAuthChanged := false isAuthChanged := false
isIncludeAllChanged := false isIncludeAllChanged := false
var includesAllRepositories = (form.RepoAccess == "all")
if !t.IsOwnerTeam() { if !t.IsOwnerTeam() {
// Validate permission level. // Validate permission level.
auth := models.ParseAccessMode(form.Permission) auth := models.ParseAccessMode(form.Permission)
t.Authorize = auth t.Authorize = auth
} }


if t.IncludesAllRepositories != form.IncludesAllRepositories {
if t.IncludesAllRepositories != includesAllRepositories {
isIncludeAllChanged = true isIncludeAllChanged = true
t.IncludesAllRepositories = form.IncludesAllRepositories
t.IncludesAllRepositories = includesAllRepositories
} }
} }
t.Description = form.Description t.Description = form.Description

+ 18
- 7
templates/org/team/new.tmpl View File

<span class="help">{{.i18n.Tr "org.team_desc_helper"}}</span> <span class="help">{{.i18n.Tr "org.team_desc_helper"}}</span>
</div> </div>
{{if not (eq .Team.LowerName "owners")}} {{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"> <div class="grouped field">
<label>{{.i18n.Tr "org.team_permission_desc"}}</label> <label>{{.i18n.Tr "org.team_permission_desc"}}</label>
<br> <br>
<span class="help">{{.i18n.Tr "org.teams.admin_access_helper"}}</span> <span class="help">{{.i18n.Tr "org.teams.admin_access_helper"}}</span>
</div> </div>
</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>
<div class="ui divider"></div> <div class="ui divider"></div>



Loading…
Cancel
Save