mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-17 19:10:22 +03:00
feat(org): add team visibility so org members can discover teams (#37680)
Closes #37670. Today, org members in Gitea only see teams they're a member of. In larger orgs that hurts onboarding and discoverability — there's no way to look up which team owns what without asking around. GitHub solves this with a per-team visibility setting; this PR brings the same model to Gitea. ## What changes - Every team gets a `visibility` setting: - `private` *(default)* — only team members and org owners can see the team. Same as today's behavior. - `limited` — listable by any member of the organization. Members and the repos the team has access to are visible too. Non-org-members still see nothing. - `public` — listable by any signed-in user. - The Owners team visibility is fixed and cannot be changed via settings. - Existing teams default to `private`, so this is a no-op for anyone who doesn't change anything. ## API - `Team`, `CreateTeamOption`, `EditTeamOption` all gain a `visibility` field (string enum: `private` | `limited` | `public`). - `GET /orgs/{org}/teams` and `/orgs/{org}/teams/search` now apply the same visibility rules as the web UI: - site admins and org owners still see every team - other org members see their own teams plus any `limited` or `public` team - `private` teams are no longer leaked through these endpoints - Swagger/OpenAPI specs regenerated. ## UI View from admin2 (not an owner): <img width="1669" height="726" src="https://github.com/user-attachments/assets/daf4bccb-644b-4426-b178-71963aeaf73b" /> View from admin (owner): <img width="2559" height="863" src="https://github.com/user-attachments/assets/4f22cebc-e9df-4fd2-8ed4-724d31fadb7a" /> --------- Signed-off-by: bircni <bircni@icloud.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -12,10 +12,10 @@
|
||||
{{template "base/alert" .}}
|
||||
<div class="required field {{if .Err_TeamName}}error{{end}}">
|
||||
<label for="team_name">{{ctx.Locale.Tr "org.team_name"}}</label>
|
||||
{{if eq .Team.LowerName "owners"}}
|
||||
{{if .Team.IsOwnerTeam}}
|
||||
<input type="hidden" name="team_name" value="{{.Team.Name}}">
|
||||
{{end}}
|
||||
<input id="team_name" name="team_name" value="{{.Team.Name}}" required {{if eq .Team.LowerName "owners"}}disabled{{end}} autofocus>
|
||||
<input id="team_name" name="team_name" value="{{.Team.Name}}" required {{if .Team.IsOwnerTeam}}disabled{{end}} autofocus>
|
||||
<span class="help">{{ctx.Locale.Tr "org.team_name_helper"}}</span>
|
||||
</div>
|
||||
<div class="field {{if .Err_Description}}error{{end}}">
|
||||
@@ -23,7 +23,47 @@
|
||||
<input id="description" name="description" value="{{.Team.Description}}" maxlength="255">
|
||||
<span class="help">{{ctx.Locale.Tr "org.team_desc_helper"}}</span>
|
||||
</div>
|
||||
{{if not (eq .Team.LowerName "owners")}}
|
||||
{{if .Team.IsOwnerTeam}}
|
||||
<div class="field">
|
||||
<label>{{ctx.Locale.Tr "org.teams.visibility"}}</label>
|
||||
<div class="tw-mb-1">
|
||||
{{if .Team.IsPrivate}}
|
||||
<span class="ui mini label">{{ctx.Locale.Tr "org.teams.visibility_private"}}</span>
|
||||
{{else if .Team.IsLimited}}
|
||||
<span class="ui mini label">{{ctx.Locale.Tr "org.teams.visibility_limited"}}</span>
|
||||
{{else if .Team.IsPublic}}
|
||||
<span class="ui mini label">{{ctx.Locale.Tr "org.teams.visibility_public"}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="help">{{ctx.Locale.Tr "org.teams.owners_visibility_fixed"}}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if not .Team.IsOwnerTeam}}
|
||||
<div class="grouped field">
|
||||
<label>{{ctx.Locale.Tr "org.teams.visibility"}}</label>
|
||||
<br>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="visibility" value="private" {{if or .PageIsOrgTeamsNew .Team.IsPrivate}}checked{{end}}>
|
||||
<label>{{ctx.Locale.Tr "org.teams.visibility_private"}}</label>
|
||||
<span class="help">{{ctx.Locale.Tr "org.teams.visibility_private_helper"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="visibility" value="limited" {{if .Team.IsLimited}}checked{{end}}>
|
||||
<label>{{ctx.Locale.Tr "org.teams.visibility_limited"}}</label>
|
||||
<span class="help">{{ctx.Locale.Tr "org.teams.visibility_limited_helper"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="visibility" value="public" {{if .Team.IsPublic}}checked{{end}}>
|
||||
<label>{{ctx.Locale.Tr "org.teams.visibility_public"}}</label>
|
||||
<span class="help">{{ctx.Locale.Tr "org.teams.visibility_public_helper"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grouped field">
|
||||
<label>{{ctx.Locale.Tr "org.team_access_desc"}}</label>
|
||||
<br>
|
||||
@@ -135,7 +175,7 @@
|
||||
<button class="ui primary button">{{ctx.Locale.Tr "org.create_team"}}</button>
|
||||
{{else}}
|
||||
<button class="ui primary button">{{ctx.Locale.Tr "org.teams.update_settings"}}</button>
|
||||
{{if not (eq .Team.LowerName "owners")}}
|
||||
{{if not .Team.IsOwnerTeam}}
|
||||
<button class="ui red button delete-button" data-url="{{.OrgLink}}/teams/{{.Team.Name | PathEscape}}/delete">{{ctx.Locale.Tr "org.teams.delete_team"}}</button>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<div class="ui six wide column">
|
||||
<h4 class="ui top attached header flex-left-right">
|
||||
<strong>{{.Team.Name}}</strong>
|
||||
<div class="flex-text-inline">
|
||||
<strong>{{.Team.Name}}</strong>
|
||||
{{if .Team.IsPrivate}}
|
||||
<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_private_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_private"}}</span>
|
||||
{{else if .Team.IsLimited}}
|
||||
<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_limited_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_limited"}}</span>
|
||||
{{else if .Team.IsPublic}}
|
||||
<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_public_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_public"}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="flex-text-block">
|
||||
{{if .Team.IsMember ctx $.SignedUser.ID}}
|
||||
<button class="ui red mini compact button show-modal" data-modal="#org-member-leave-team"
|
||||
@@ -26,7 +35,7 @@
|
||||
|
||||
<div class="ui attached segment">
|
||||
{{/* TODO: old indent is kept to make diff changes minimal, can be reformatted in the future */}}
|
||||
{{if eq .Team.LowerName "owners"}}
|
||||
{{if .Team.IsOwnerTeam}}
|
||||
<p>{{ctx.Locale.Tr "org.teams.owners_permission_desc"}}</p>
|
||||
<p>{{ctx.Locale.Tr "org.teams.owners_permission_suggestion"}}</p>
|
||||
{{else}}
|
||||
|
||||
@@ -21,7 +21,16 @@
|
||||
{{range $team := $.OrgListTeams}}
|
||||
<div class="column team-item-box">
|
||||
<div class="ui top attached header muted-links flex-left-right team-item-header">
|
||||
<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}"><strong>{{.Name}}</strong></a>
|
||||
<div class="flex-text-inline">
|
||||
<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}"><strong>{{.Name}}</strong></a>
|
||||
{{if .IsPrivate}}
|
||||
<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_private_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_private"}}</span>
|
||||
{{else if .IsLimited}}
|
||||
<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_limited_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_limited"}}</span>
|
||||
{{else if .IsPublic}}
|
||||
<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_public_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_public"}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="flex-text-block tw-flex-wrap">
|
||||
<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}">{{.NumMembers}} {{ctx.Locale.Tr "org.lower_members"}}</a>
|
||||
·
|
||||
|
||||
Generated
+33
@@ -24992,6 +24992,17 @@
|
||||
},
|
||||
"x-go-name": "UnitsMap",
|
||||
"example": "{\"repo.actions\",\"repo.packages\",\"repo.code\":\"read\",\"repo.issues\":\"write\",\"repo.ext_issues\":\"none\",\"repo.wiki\":\"admin\",\"repo.pulls\":\"owner\",\"repo.releases\":\"none\",\"repo.projects\":\"none\",\"repo.ext_wiki\":\"none\"}"
|
||||
},
|
||||
"visibility": {
|
||||
"description": "Team visibility within the organization. Defaults to \"private\".\npublic TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"public",
|
||||
"limited",
|
||||
"private"
|
||||
],
|
||||
"x-go-enum-desc": "public TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate",
|
||||
"x-go-name": "Visibility"
|
||||
}
|
||||
},
|
||||
"x-go-package": "gitea.dev/modules/structs"
|
||||
@@ -26190,6 +26201,17 @@
|
||||
"repo.releases": "none",
|
||||
"repo.wiki": "admin"
|
||||
}
|
||||
},
|
||||
"visibility": {
|
||||
"description": "Team visibility within the organization. When omitted, visibility is\nleft unchanged.\npublic TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"public",
|
||||
"limited",
|
||||
"private"
|
||||
],
|
||||
"x-go-enum-desc": "public TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate",
|
||||
"x-go-name": "Visibility"
|
||||
}
|
||||
},
|
||||
"x-go-package": "gitea.dev/modules/structs"
|
||||
@@ -30096,6 +30118,17 @@
|
||||
"repo.releases": "none",
|
||||
"repo.wiki": "admin"
|
||||
}
|
||||
},
|
||||
"visibility": {
|
||||
"description": "Team visibility within the organization. \"private\" teams are only\nlistable by members and org owners; \"limited\" teams are listable by\nany organization member; \"public\" teams are listable by any signed-in\nuser.\npublic TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"public",
|
||||
"limited",
|
||||
"private"
|
||||
],
|
||||
"x-go-enum-desc": "public TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate",
|
||||
"x-go-name": "Visibility"
|
||||
}
|
||||
},
|
||||
"x-go-package": "gitea.dev/modules/structs"
|
||||
|
||||
Generated
+32
@@ -4805,6 +4805,14 @@
|
||||
"example": "{\"repo.actions\",\"repo.packages\",\"repo.code\":\"read\",\"repo.issues\":\"write\",\"repo.ext_issues\":\"none\",\"repo.wiki\":\"admin\",\"repo.pulls\":\"owner\",\"repo.releases\":\"none\",\"repo.projects\":\"none\",\"repo.ext_wiki\":\"none\"}",
|
||||
"type": "object",
|
||||
"x-go-name": "UnitsMap"
|
||||
},
|
||||
"visibility": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/TeamVisibility"
|
||||
}
|
||||
],
|
||||
"description": "Team visibility within the organization. Defaults to \"private\".\npublic TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -5991,6 +5999,14 @@
|
||||
},
|
||||
"type": "object",
|
||||
"x-go-name": "UnitsMap"
|
||||
},
|
||||
"visibility": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/TeamVisibility"
|
||||
}
|
||||
],
|
||||
"description": "Team visibility within the organization. When omitted, visibility is\nleft unchanged.\npublic TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -9938,11 +9954,27 @@
|
||||
},
|
||||
"type": "object",
|
||||
"x-go-name": "UnitsMap"
|
||||
},
|
||||
"visibility": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/TeamVisibility"
|
||||
}
|
||||
],
|
||||
"description": "Team visibility within the organization. \"private\" teams are only\nlistable by members and org owners; \"limited\" teams are listable by\nany organization member; \"public\" teams are listable by any signed-in\nuser.\npublic TeamVisibilityPublic\nlimited TeamVisibilityLimited\nprivate TeamVisibilityPrivate"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"x-go-package": "gitea.dev/modules/structs"
|
||||
},
|
||||
"TeamVisibility": {
|
||||
"enum": [
|
||||
"public",
|
||||
"limited",
|
||||
"private"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"TimeStamp": {
|
||||
"description": "TimeStamp defines a timestamp",
|
||||
"format": "int64",
|
||||
|
||||
Reference in New Issue
Block a user