Skip to content

feat: show organization name for groups on user profile #14448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 29, 2024
Merged
Prev Previous commit
Next Next commit
hmm
  • Loading branch information
aslilac committed Aug 27, 2024
commit 013b4223cd17d12e6b0d5910d5f1e6b704cebdd4
21 changes: 11 additions & 10 deletions coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,18 @@ func Users(users []database.User, organizationIDs map[uuid.UUID][]uuid.UUID) []c
})
}

func Group(group database.Group, members []database.GroupMember, totalMemberCount int) codersdk.Group {
func Group(group database.GetGroupsRow, members []database.GroupMember, totalMemberCount int) codersdk.Group {
return codersdk.Group{
ID: group.ID,
Name: group.Name,
DisplayName: group.DisplayName,
OrganizationID: group.OrganizationID,
AvatarURL: group.AvatarURL,
Members: ReducedUsersFromGroupMembers(members),
TotalMemberCount: totalMemberCount,
QuotaAllowance: int(group.QuotaAllowance),
Source: codersdk.GroupSource(group.Source),
ID: group.Group.ID,
Name: group.Group.Name,
DisplayName: group.Group.DisplayName,
OrganizationID: group.Group.OrganizationID,
OrganizationDisplayName: group.OrganizationDisplayName,
AvatarURL: group.Group.AvatarURL,
Members: ReducedUsersFromGroupMembers(members),
TotalMemberCount: totalMemberCount,
QuotaAllowance: int(group.Group.QuotaAllowance),
Source: codersdk.GroupSource(group.Group.Source),
}
}

Expand Down
4 changes: 4 additions & 0 deletions coderd/database/modelmethods.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func (g Group) RBACObject() rbac.Object {
})
}

func (g GetGroupsRow) RBACObject() rbac.Object {
return g.Group.RBACObject()
}

func (gm GroupMember) RBACObject() rbac.Object {
return rbac.ResourceGroupMember.WithID(gm.UserID).InOrg(gm.OrganizationID).WithOwner(gm.UserID.String())
}
Expand Down
2 changes: 1 addition & 1 deletion coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
}
ownerGroupNames := []string{}
for _, group := range ownerGroups {
ownerGroupNames = append(ownerGroupNames, group.Name)
ownerGroupNames = append(ownerGroupNames, group.Group.Name)
}
err = s.Pubsub.Publish(codersdk.WorkspaceNotifyChannel(workspace.ID), []byte{})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions enterprise/coderd/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
var emptyMembers []database.GroupMember
aReq.New = group.Auditable(emptyMembers)

httpapi.Write(ctx, rw, http.StatusCreated, db2sdk.Group(group, nil, 0))

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-e2e

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / lint

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / gen

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 81 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group
}

// @Summary Update group by name
Expand Down Expand Up @@ -289,7 +289,7 @@
return
}

httpapi.Write(ctx, rw, http.StatusOK, db2sdk.Group(group, patchedMembers, int(memberCount)))

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-e2e

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / lint

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / gen

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 292 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group
}

// @Summary Delete group by name
Expand Down Expand Up @@ -380,7 +380,7 @@
return
}

httpapi.Write(ctx, rw, http.StatusOK, db2sdk.Group(group, users, int(memberCount)))

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-e2e

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / lint

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / gen

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 383 in enterprise/coderd/groups.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.Group) as database.GetGroupsRow value in argument to db2sdk.Group
}

// @Summary Get groups by organization
Expand Down Expand Up @@ -456,12 +456,12 @@

resp := make([]codersdk.Group, 0, len(groups))
for _, group := range groups {
members, err := api.Database.GetGroupMembersByGroupID(ctx, group.ID)
members, err := api.Database.GetGroupMembersByGroupID(ctx, group.Group.ID)
if err != nil {
httpapi.InternalServerError(rw, err)
return
}
memberCount, err := api.Database.GetGroupMembersCountByGroupID(ctx, group.ID)
memberCount, err := api.Database.GetGroupMembersCountByGroupID(ctx, group.Group.ID)
if err != nil {
httpapi.InternalServerError(rw, err)
return
Expand Down
2 changes: 1 addition & 1 deletion enterprise/coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
sdkGroups := make([]codersdk.Group, 0, len(groups))
for _, group := range groups {
// nolint:gocritic
members, err := api.Database.GetGroupMembersByGroupID(dbauthz.AsSystemRestricted(ctx), group.ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-e2e

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / lint

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / gen

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-race

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-race

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 64 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

group.ID undefined (type database.GetGroupsRow has no field or method ID)
if err != nil {
httpapi.InternalServerError(rw, err)
return
}
memberCount, err := api.Database.GetGroupMembersCountByGroupID(ctx, group.ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-e2e

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / lint

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / gen

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-race

group.ID undefined (type database.GetGroupsRow has no field or method ID)

Check failure on line 69 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

group.ID undefined (type database.GetGroupsRow has no field or method ID)
if err != nil {
httpapi.InternalServerError(rw, err)
return
Expand Down Expand Up @@ -147,7 +147,7 @@
return
}
groups = append(groups, codersdk.TemplateGroup{
Group: db2sdk.Group(group.Group, members, int(memberCount)),
Group: db2sdk.Group(group, members, int(memberCount)),

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-e2e

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / lint

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group) (typecheck)

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / gen

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go-race

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group

Check failure on line 150 in enterprise/coderd/templates.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

cannot use group (variable of type database.TemplateGroup) as database.GetGroupsRow value in argument to db2sdk.Group
Role: convertToTemplateRole(group.Actions),
})
}
Expand Down
Loading