From b478a100776f09f97eb9953b8e34e73a064c9b54 Mon Sep 17 00:00:00 2001 From: Nicolas Gourdon Date: Sun, 28 Apr 2019 10:12:15 +0200 Subject: [PATCH] Add AllRepositories to team UI --- modules/auth/org.go | 9 +++++---- options/locale/locale_en-US.ini | 5 +++++ routers/org/teams.go | 12 ++++++++---- templates/org/team/new.tmpl | 7 +++++++ templates/org/team/repositories.tmpl | 2 +- templates/org/team/sidebar.tmpl | 18 +++++++++++++++--- 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/modules/auth/org.go b/modules/auth/org.go index d51ab75d3a..25963a5a07 100644 --- a/modules/auth/org.go +++ b/modules/auth/org.go @@ -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 diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index eedede2a05..178fc5a075 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -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 Read access to all repositories: members can view and clone repositories. +teams.all_repositories_write_permission_desc = This team grants Write access to all repositories: members can read from and push to repositories. +teams.all_repositories_admin_permission_desc = This team grants Admin access to all repositories: members can read from, push to and add collaborators to repositories. [admin] dashboard = Dashboard diff --git a/routers/org/teams.go b/routers/org/teams.go index 27db14e4b5..dc52fb5b0e 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -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 { diff --git a/templates/org/team/new.tmpl b/templates/org/team/new.tmpl index fb79c9b7fb..c32b482224 100644 --- a/templates/org/team/new.tmpl +++ b/templates/org/team/new.tmpl @@ -24,6 +24,13 @@ {{.i18n.Tr "org.team_desc_helper"}} {{if not (eq .Team.LowerName "owners")}} +
+
+ + + {{.i18n.Tr "org.teams.all_repositories_helper"}} +
+

diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index eeb86564fd..49f08bb724 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -7,7 +7,7 @@ {{template "org/team/sidebar" .}}
{{template "org/team/navbar" .}} - {{$canAddRemove := and $.IsOrganizationOwner (not (eq $.Team.LowerName "owners"))}} + {{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IsAllRepositories)}} {{if $canAddRemove}}
diff --git a/templates/org/team/sidebar.tmpl b/templates/org/team/sidebar.tmpl index 846613e32e..840089daf0 100644 --- a/templates/org/team/sidebar.tmpl +++ b/templates/org/team/sidebar.tmpl @@ -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}}