{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings collaboration")}}

{{ctx.Locale.Tr "repo.settings.collaboration"}}

{{if .Collaborators}}
{{range .Collaborators}}
{{template "shared/user/name" .}}
{{svg "octicon-shield-lock"}}
{{end}}
{{end}}
{{.CsrfTokenHtml}}
{{if .RepoOwnerIsOrganization}}

{{ctx.Locale.Tr "repo.settings.teams"}}

{{$allowedToChangeTeams := (or (.Org.RepoAdminChangeTeamAccess) (.Permission.IsOwner))}} {{if .Teams}}
{{range $t, $team := .Teams}}
{{.Name}}
{{svg "octicon-shield-lock"}} {{if eq .AccessMode 1}}{{ctx.Locale.Tr "repo.settings.collaboration.read"}}{{else if eq .AccessMode 2}}{{ctx.Locale.Tr "repo.settings.collaboration.write"}}{{else if eq .AccessMode 3}}{{ctx.Locale.Tr "repo.settings.collaboration.admin"}}{{else if eq .AccessMode 4}}{{ctx.Locale.Tr "repo.settings.collaboration.owner"}}{{else}}{{ctx.Locale.Tr "repo.settings.collaboration.undefined"}}{{end}}
{{if or (eq .AccessMode 1) (eq .AccessMode 2)}} {{$first := true}}
Sections: {{range $u, $unit := $.Units}}{{if and ($.Repo.UnitEnabled $.Context $unit.Type) ($team.UnitEnabled $.Context $unit.Type)}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{ctx.Locale.Tr $unit.NameKey}}{{end}}{{end}} {{if $first}}None{{end}}
{{end}}
{{if $allowedToChangeTeams}}
{{end}}
{{end}}
{{end}}
{{if $allowedToChangeTeams}}
{{.CsrfTokenHtml}}
{{else}}
{{ctx.Locale.Tr "repo.settings.change_team_access_not_allowed"}}
{{end}}
{{end}}
{{template "repo/settings/layout_footer" .}}