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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
somethin'
  • Loading branch information
aslilac committed Aug 27, 2024
commit d0cf4540a38738bd7a48b3db70f4e40d31b8cc4e
3 changes: 0 additions & 3 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ func Group(group database.Group, members []database.GroupMember, totalMemberCoun
}
}

func GroupWithOrganizationInfo(group database.Group, orgDisplayName string, members []database.GroupMember, totalMemberCount int) codersdk.GroupWithOrganizationInfo {
func GroupWithOrganizationInfo(group database.Group, orgName, orgDisplayName string, members []database.GroupMember, totalMemberCount int) codersdk.GroupWithOrganizationInfo {
sdkGroup := Group(group, members, totalMemberCount)
return codersdk.GroupWithOrganizationInfo{
Group: sdkGroup,
OrganizationName: orgName,
OrganizationDisplayName: orgDisplayName,
}
}
Expand Down
6 changes: 5 additions & 1 deletion coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion coderd/database/queries/groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ LIMIT

-- name: GetGroups :many
SELECT
sqlc.embed(groups), organizations.display_name AS organization_display_name
sqlc.embed(groups),
organizations.name AS organization_name,
organizations.display_name AS organization_display_name
FROM
groups
INNER JOIN
Expand Down
18 changes: 9 additions & 9 deletions coderd/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (r *remoteReporter) createSnapshot() (*Snapshot, error) {
}
snapshot.Groups = make([]Group, 0, len(groups))
for _, group := range groups {
snapshot.Groups = append(snapshot.Groups, ConvertGroup(group))
snapshot.Groups = append(snapshot.Groups, ConvertGroup(group.Group))
}
return nil
})
Expand Down Expand Up @@ -669,15 +669,15 @@ func ConvertUser(dbUser database.User) User {
}
}

func ConvertGroup(row database.GetGroupsRow) Group {
func ConvertGroup(group database.Group) Group {
return Group{
ID: row.Group.ID,
Name: row.Group.Name,
OrganizationID: row.Group.OrganizationID,
AvatarURL: row.Group.AvatarURL,
QuotaAllowance: row.Group.QuotaAllowance,
DisplayName: row.Group.DisplayName,
Source: row.Group.Source,
ID: group.ID,
Name: group.Name,
OrganizationID: group.OrganizationID,
AvatarURL: group.AvatarURL,
QuotaAllowance: group.QuotaAllowance,
DisplayName: group.DisplayName,
Source: group.Source,
}
}

Expand Down
12 changes: 6 additions & 6 deletions codersdk/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ type CreateGroupRequest struct {
}

type Group struct {
ID uuid.UUID `json:"id" format:"uuid"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
OrganizationDisplayName string `json:"organization_display_name"`
Members []ReducedUser `json:"members"`
ID uuid.UUID `json:"id" format:"uuid"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
Members []ReducedUser `json:"members"`
// How many members are in this group. Shows the total count,
// even if the user is not authorized to read group member details.
// May be greater than `len(Group.Members)`.
Expand All @@ -43,6 +42,7 @@ type Group struct {

type GroupWithOrganizationInfo struct {
Group
OrganizationName string `json:"organization_name"`
OrganizationDisplayName string `json:"organization_display_name"`
}

Expand Down
Loading
Loading