Add AllRepositories to team UI

This commit is contained in:
Nicolas Gourdon 2019-04-28 10:12:15 +02:00
parent 0b8e90e39b
commit b478a10077
6 changed files with 41 additions and 12 deletions

View file

@ -56,10 +56,11 @@ func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs binding.Error
// CreateTeamForm form for creating team
type CreateTeamForm struct {
TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `binding:"MaxSize(255)"`
Permission string
Units []models.UnitType
TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `binding:"MaxSize(255)"`
Permission string
Units []models.UnitType
IsAllRepositories bool
}
// Validate validates the fields

View file

@ -1452,6 +1452,11 @@ 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.all_repositories = All repositories
teams.all_repositories_helper = Team has access to all 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.
teams.all_repositories_write_permission_desc = This team grants <strong>Write</strong> access to <strong>all repositories</strong>: members can read from and push to repositories.
teams.all_repositories_admin_permission_desc = This team grants <strong>Admin</strong> access to <strong>all repositories</strong>: members can read from, push to and add collaborators to repositories.
[admin]
dashboard = Dashboard

View file

@ -1,4 +1,5 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@ -181,10 +182,11 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
ctx.Data["Units"] = models.Units
t := &models.Team{
OrgID: ctx.Org.Organization.ID,
Name: form.TeamName,
Description: form.Description,
Authorize: models.ParseAccessMode(form.Permission),
OrgID: ctx.Org.Organization.ID,
Name: form.TeamName,
Description: form.Description,
Authorize: models.ParseAccessMode(form.Permission),
IsAllRepositories: form.IsAllRepositories,
}
if t.Authorize < models.AccessModeOwner {
@ -276,6 +278,8 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
isAuthChanged = true
t.Authorize = auth
}
t.IsAllRepositories = form.IsAllRepositories
}
t.Description = form.Description
if t.Authorize < models.AccessModeOwner {

View file

@ -24,6 +24,13 @@
<span class="help">{{.i18n.Tr "org.team_desc_helper"}}</span>
</div>
{{if not (eq .Team.LowerName "owners")}}
<div class="inline field">
<div class="ui checkbox">
<label for="is_all_repositories">{{.i18n.Tr "org.teams.all_repositories"}}</label>
<input id="is_all_repositories" name="is_all_repositories" type="checkbox" {{if .Team.IsAllRepositories}}checked{{end}}>
<span class="help">{{.i18n.Tr "org.teams.all_repositories_helper"}}</span>
</div>
</div>
<div class="grouped field">
<label>{{.i18n.Tr "org.team_permission_desc"}}</label>
<br>

View file

@ -7,7 +7,7 @@
{{template "org/team/sidebar" .}}
<div class="ui ten wide column">
{{template "org/team/navbar" .}}
{{$canAddRemove := and $.IsOrganizationOwner (not (eq $.Team.LowerName "owners"))}}
{{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IsAllRepositories)}}
{{if $canAddRemove}}
<div class="ui attached segment">
<form class="ui form" id="add-repo-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/repo/add" method="post">

View file

@ -22,11 +22,23 @@
{{if eq .Team.LowerName "owners"}}
{{.i18n.Tr "org.teams.owners_permission_desc" | Str2html}}
{{else if (eq .Team.Authorize 1)}}
{{.i18n.Tr "org.teams.read_permission_desc" | Str2html}}
{{if .Team.IsAllRepositories}}
{{.i18n.Tr "org.teams.all_repositories_read_permission_desc" | Str2html}}
{{else}}
{{.i18n.Tr "org.teams.read_permission_desc" | Str2html}}
{{end}}
{{else if (eq .Team.Authorize 2)}}
{{.i18n.Tr "org.teams.write_permission_desc" | Str2html}}
{{if .Team.IsAllRepositories}}
{{.i18n.Tr "org.teams.all_repositories_write_permission_desc" | Str2html}}
{{else}}
{{.i18n.Tr "org.teams.write_permission_desc" | Str2html}}
{{end}}
{{else if (eq .Team.Authorize 3)}}
{{.i18n.Tr "org.teams.admin_permission_desc" | Str2html}}
{{if .Team.IsAllRepositories}}
{{.i18n.Tr "org.teams.all_repositories_admin_permission_desc" | Str2html}}
{{else}}
{{.i18n.Tr "org.teams.admin_permission_desc" | Str2html}}
{{end}}
{{end}}
</div>
</div>