From 8d82d52c304da1b0c152d6b6f7b95a3e6cc0128c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 14 Aug 2025 22:09:45 -0400 Subject: [PATCH] add templates for pages to add and manage teams with access to a group --- models/activities/action.go | 2 + models/activities/user_heatmap.go | 10 ++- models/shared/group/group_item.go | 3 +- templates/group/team/new.tmpl | 144 ++++++++++++++++++++++++++++++ templates/group/team/teams.tmpl | 104 +++++++++++++++++++++ templates/org/team/teams.tmpl | 5 ++ 6 files changed, 263 insertions(+), 5 deletions(-) create mode 100644 templates/group/team/new.tmpl create mode 100644 templates/group/team/teams.tmpl diff --git a/models/activities/action.go b/models/activities/action.go index cd968e8e98..ed63b070fd 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -15,6 +15,7 @@ import ( "time" "code.gitea.io/gitea/models/db" + group_model "code.gitea.io/gitea/models/group" issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/models/organization" repo_model "code.gitea.io/gitea/models/repo" @@ -451,6 +452,7 @@ type GetFeedsOptions struct { RequestedUser *user_model.User // the user we want activity for RequestedTeam *organization.Team // the team we want activity for RequestedRepo *repo_model.Repository // the repo we want activity for + RequestedGroup *group_model.Group // the repo group we want activity for Actor *user_model.User // the user viewing the activity IncludePrivate bool // include private actions OnlyPerformedBy bool // only actions performed by requested user diff --git a/models/activities/user_heatmap.go b/models/activities/user_heatmap.go index e24d44c519..58e98567ea 100644 --- a/models/activities/user_heatmap.go +++ b/models/activities/user_heatmap.go @@ -7,6 +7,7 @@ import ( "context" "code.gitea.io/gitea/models/db" + group_model "code.gitea.io/gitea/models/group" "code.gitea.io/gitea/models/organization" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/setting" @@ -21,15 +22,15 @@ type UserHeatmapData struct { // GetUserHeatmapDataByUser returns an array of UserHeatmapData, it checks whether doer can access user's activity func GetUserHeatmapDataByUser(ctx context.Context, user, doer *user_model.User) ([]*UserHeatmapData, error) { - return getUserHeatmapData(ctx, user, nil, doer) + return getUserHeatmapData(ctx, user, nil, nil, doer) } // GetUserHeatmapDataByOrgTeam returns an array of UserHeatmapData, it checks whether doer can access org's activity -func GetUserHeatmapDataByOrgTeam(ctx context.Context, org *organization.Organization, team *organization.Team, doer *user_model.User) ([]*UserHeatmapData, error) { - return getUserHeatmapData(ctx, org.AsUser(), team, doer) +func GetUserHeatmapDataByOrgTeam(ctx context.Context, org *organization.Organization, team *organization.Team, group *group_model.Group, doer *user_model.User) ([]*UserHeatmapData, error) { + return getUserHeatmapData(ctx, org.AsUser(), team, group, doer) } -func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organization.Team, doer *user_model.User) ([]*UserHeatmapData, error) { +func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organization.Team, group *group_model.Group, doer *user_model.User) ([]*UserHeatmapData, error) { hdata := make([]*UserHeatmapData, 0) if !ActivityReadable(user, doer) { @@ -53,6 +54,7 @@ func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organi Actor: doer, IncludePrivate: true, // don't filter by private, as we already filter by repo access IncludeDeleted: true, + RequestedGroup: group, // * Heatmaps for individual users only include actions that the user themself did. // * For organizations actions by all users that were made in owned // repositories are counted. diff --git a/models/shared/group/group_item.go b/models/shared/group/group_item.go index a46ce91ab9..61fae9c67d 100644 --- a/models/shared/group/group_item.go +++ b/models/shared/group/group_item.go @@ -1,6 +1,7 @@ package group import ( + "code.gitea.io/gitea/models/perm" "context" "slices" @@ -102,7 +103,7 @@ func GetTopLevelGroupItemList(ctx context.Context, orgID int64, doer *user_model ActorID: doer.ID, OwnerID: orgID, }, group_model. - AccessibleGroupCondition(doer, unit.TypeInvalid)) + AccessibleGroupCondition(doer, unit.TypeInvalid, perm.AccessModeRead)) if err != nil { return } diff --git a/templates/group/team/new.tmpl b/templates/group/team/new.tmpl new file mode 100644 index 0000000000..ea4beeadc4 --- /dev/null +++ b/templates/group/team/new.tmpl @@ -0,0 +1,144 @@ +{{template "base/head" .}} +
+ {{template "group/header" .}} +
+
+
+
+ {{.CsrfTokenHtml}} +

+ {{ctx.Locale.Tr "org.teams.settings"}} +

+
+ {{template "base/alert" .}} + {{if not (eq .Team.LowerName "owners")}} +
+ +
+
+
+ + + {{ctx.Locale.Tr "org.teams.specific_repositories_helper"}} +
+
+
+
+ + + {{ctx.Locale.Tr "org.teams.all_repositories_helper"}} +
+
+ +
+
+ + + {{ctx.Locale.Tr "org.teams.can_create_org_repo_helper"}} +
+
+
+
+ +
+
+
+ + + {{ctx.Locale.Tr "org.teams.general_access_helper"}} +
+
+
+
+ + + {{ctx.Locale.Tr "org.teams.admin_access_helper"}} +
+
+
+
+ +
+ + + + + + + + + + + + {{range $t, $unit := $.Units}} + {{if ge $unit.MaxPerm 2}} + + + + + + + {{end}} + {{end}} + +
{{ctx.Locale.Tr "units.unit"}}{{ctx.Locale.Tr "org.teams.none_access"}} + {{svg "octicon-question" 16 "tw-ml-1"}}{{ctx.Locale.Tr "org.teams.read_access"}} + {{svg "octicon-question" 16 "tw-ml-1"}}{{ctx.Locale.Tr "org.teams.write_access"}} + {{svg "octicon-question" 16 "tw-ml-1"}}
+
+
+ + {{ctx.Locale.Tr $unit.DescKey}} +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+ {{range $t, $unit := $.Units}} + {{if lt $unit.MaxPerm 2}} +
+
+ + + {{ctx.Locale.Tr $unit.DescKey}} +
+
+ {{end}} + {{end}} +
+ {{end}} + +
+ + {{if not (eq .Team.LowerName "owners")}} + + {{end}} +
+
+
+
+
+
+
+ + +{{template "base/footer" .}} diff --git a/templates/group/team/teams.tmpl b/templates/group/team/teams.tmpl new file mode 100644 index 0000000000..dc0e846496 --- /dev/null +++ b/templates/group/team/teams.tmpl @@ -0,0 +1,104 @@ +{{template "base/head" .}} +
+ {{template "group/header" .}} +
+ {{ template "base/alert" .}} + +
+
+
+ {{if or .IsGroupAdmin .IsGroupOwner}} + +
+
+
+ {{.CsrfTokenHtml}} + + + +
+
+
+ {{end}} + {{range .Teams}} +
+
+ {{.Name}} +
+ {{ctx.Locale.Tr "view"}} + + {{if .IsMember ctx $.SignedUser.ID}} +
+ +
+ {{else if $.IsOrganizationOwner}} +
+ {{$.CsrfTokenHtml}} + +
+ {{end}} + + {{if and (or $.IsGroupAdmin $.IsGroupOwner) (not .IsOwnerTeam)}} +
+ +
+ {{end}} +
+
+
+ {{range .Members}} + {{template "shared/user/avatarlink" dict "user" .}} + {{end}} +
+ +
+ {{end}} +
+
+
+ {{template "group/sidebar/menu" .}} +
+
+
+
+ + +{{template "base/footer" .}} diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 5ea15068fe..e3de070f8c 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -1,6 +1,10 @@ {{template "base/head" .}}
+ {{if .PageIsOrgTeams}} {{template "org/header" .}} + {{else if .PageIsGroupTeams}} + {{template "group/header" .}} + {{end}}
{{template "base/alert" .}} {{if .IsOrganizationOwner}} @@ -18,6 +22,7 @@ {{.Name}}
{{ctx.Locale.Tr "view"}} + {{if .IsMember ctx $.SignedUser.ID}}