Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49afab1

Browse files
authored
feat: show organization name for groups on user profile (#14448)
1 parent4b5c45d commit49afab1

File tree

29 files changed

+357
-229
lines changed

29 files changed

+357
-229
lines changed

‎coderd/apidoc/docs.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/db2sdk/db2sdk.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,19 @@ func Users(users []database.User, organizationIDs map[uuid.UUID][]uuid.UUID) []c
208208
})
209209
}
210210

211-
funcGroup(group database.Group,members []database.GroupMember,totalMemberCountint) codersdk.Group {
211+
funcGroup(row database.GetGroupsRow,members []database.GroupMember,totalMemberCountint) codersdk.Group {
212212
return codersdk.Group{
213-
ID:group.ID,
214-
Name:group.Name,
215-
DisplayName:group.DisplayName,
216-
OrganizationID:group.OrganizationID,
217-
AvatarURL:group.AvatarURL,
218-
Members:ReducedUsersFromGroupMembers(members),
219-
TotalMemberCount:totalMemberCount,
220-
QuotaAllowance:int(group.QuotaAllowance),
221-
Source:codersdk.GroupSource(group.Source),
213+
ID:row.Group.ID,
214+
Name:row.Group.Name,
215+
DisplayName:row.Group.DisplayName,
216+
OrganizationID:row.Group.OrganizationID,
217+
AvatarURL:row.Group.AvatarURL,
218+
Members:ReducedUsersFromGroupMembers(members),
219+
TotalMemberCount:totalMemberCount,
220+
QuotaAllowance:int(row.Group.QuotaAllowance),
221+
Source:codersdk.GroupSource(row.Group.Source),
222+
OrganizationName:row.OrganizationName,
223+
OrganizationDisplayName:row.OrganizationDisplayName,
222224
}
223225
}
224226

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ func (q *querier) GetGroupMembersCountByGroupID(ctx context.Context, groupID uui
15031503
returnmemberCount,nil
15041504
}
15051505

1506-
func (q*querier)GetGroups(ctx context.Context,arg database.GetGroupsParams) ([]database.Group,error) {
1506+
func (q*querier)GetGroups(ctx context.Context,arg database.GetGroupsParams) ([]database.GetGroupsRow,error) {
15071507
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceSystem);err==nil {
15081508
// Optimize this query for system users as it is used in telemetry.
15091509
// Calling authz on all groups in a deployment for telemetry jobs is

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,10 @@ func (s *MethodTestSuite) TestOrganization() {
607607
check.Args(database.GetGroupsParams{
608608
OrganizationID:o.ID,
609609
}).Asserts(rbac.ResourceSystem,policy.ActionRead,a,policy.ActionRead,b,policy.ActionRead).
610-
Returns([]database.Group{a,b}).
610+
Returns([]database.GetGroupsRow{
611+
{Group:a,OrganizationName:o.Name,OrganizationDisplayName:o.DisplayName},
612+
{Group:b,OrganizationName:o.Name,OrganizationDisplayName:o.DisplayName},
613+
}).
611614
// Fail the system check shortcut
612615
FailSystemObjectChecks()
613616
}))

‎coderd/database/dbmem/dbmem.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,7 @@ func (q *FakeQuerier) GetGroupMembersCountByGroupID(ctx context.Context, groupID
26092609
returnint64(len(users)),nil
26102610
}
26112611

2612-
func (q*FakeQuerier)GetGroups(_ context.Context,arg database.GetGroupsParams) ([]database.Group,error) {
2612+
func (q*FakeQuerier)GetGroups(_ context.Context,arg database.GetGroupsParams) ([]database.GetGroupsRow,error) {
26132613
err:=validateDatabaseType(arg)
26142614
iferr!=nil {
26152615
returnnil,err
@@ -2634,7 +2634,8 @@ func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams)
26342634
}
26352635
}
26362636

2637-
filtered:=make([]database.Group,0)
2637+
orgDetailsCache:=make(map[uuid.UUID]struct{name,displayNamestring })
2638+
filtered:=make([]database.GetGroupsRow,0)
26382639
for_,group:=rangeq.groups {
26392640
ifarg.OrganizationID!=uuid.Nil&&group.OrganizationID!=arg.OrganizationID {
26402641
continue
@@ -2645,7 +2646,24 @@ func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams)
26452646
continue
26462647
}
26472648

2648-
filtered=append(filtered,group)
2649+
orgDetails,ok:=orgDetailsCache[group.ID]
2650+
if!ok {
2651+
for_,org:=rangeq.organizations {
2652+
ifgroup.OrganizationID==org.ID {
2653+
orgDetails=struct{name,displayNamestring }{
2654+
name:org.Name,displayName:org.DisplayName,
2655+
}
2656+
break
2657+
}
2658+
}
2659+
orgDetailsCache[group.ID]=orgDetails
2660+
}
2661+
2662+
filtered=append(filtered, database.GetGroupsRow{
2663+
Group:group,
2664+
OrganizationName:orgDetails.name,
2665+
OrganizationDisplayName:orgDetails.displayName,
2666+
})
26492667
}
26502668

26512669
returnfiltered,nil

‎coderd/database/dbmetrics/dbmetrics.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/modelmethods.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ func (g Group) RBACObject() rbac.Object {
183183
})
184184
}
185185

186+
func (gGetGroupsRow)RBACObject() rbac.Object {
187+
returng.Group.RBACObject()
188+
}
189+
186190
func (gmGroupMember)RBACObject() rbac.Object {
187191
returnrbac.ResourceGroupMember.WithID(gm.UserID).InOrg(gm.OrganizationID).WithOwner(gm.UserID.String())
188192
}

‎coderd/database/querier.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 52 additions & 40 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/groups.sql

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,36 @@ LIMIT
2222

2323
-- name: GetGroups :many
2424
SELECT
25-
*
25+
sqlc.embed(groups),
26+
organizations.nameAS organization_name,
27+
organizations.display_nameAS organization_display_name
2628
FROM
27-
groups
29+
groups
30+
INNER JOIN
31+
organizationsONgroups.organization_id=organizations.id
2832
WHERE
29-
true
30-
AND CASE
31-
WHEN @organization_id:: uuid!='00000000-0000-0000-0000-000000000000'::uuid THEN
32-
groups.organization_id= @organization_id
33-
ELSE true
34-
END
35-
AND CASE
36-
-- Filter to only include groups a user is a member of
37-
WHEN @has_member_id::uuid!='00000000-0000-0000-0000-000000000000'::uuid THEN
38-
EXISTS (
39-
SELECT
40-
1
41-
FROM
42-
-- this view handles the 'everyone' group in orgs.
43-
group_members_expanded
44-
WHERE
45-
group_members_expanded.group_id=groups.id
46-
AND
47-
group_members_expanded.user_id= @has_member_id
48-
)
49-
ELSE true
50-
END
33+
true
34+
AND CASE
35+
WHEN @organization_id:: uuid!='00000000-0000-0000-0000-000000000000'::uuid THEN
36+
groups.organization_id= @organization_id
37+
ELSE true
38+
END
39+
AND CASE
40+
-- Filter to only include groups a user is a member of
41+
WHEN @has_member_id::uuid!='00000000-0000-0000-0000-000000000000'::uuid THEN
42+
EXISTS (
43+
SELECT
44+
1
45+
FROM
46+
-- this view handles the 'everyone' group in orgs.
47+
group_members_expanded
48+
WHERE
49+
group_members_expanded.group_id=groups.id
50+
AND
51+
group_members_expanded.user_id= @has_member_id
52+
)
53+
ELSE true
54+
END
5155
;
5256

5357
-- name: InsertGroup :one
@@ -70,15 +74,15 @@ INSERT INTO groups (
7074
id,
7175
name,
7276
organization_id,
73-
source
77+
source
7478
)
7579
SELECT
76-
gen_random_uuid(),
77-
group_name,
78-
@organization_id,
79-
@source
80+
gen_random_uuid(),
81+
group_name,
82+
@organization_id,
83+
@source
8084
FROM
81-
UNNEST(@group_names ::text[])AS group_name
85+
UNNEST(@group_names ::text[])AS group_name
8286
-- If the name conflicts, do nothing.
8387
ON CONFLICT DO NOTHING
8488
RETURNING*;
@@ -113,5 +117,3 @@ DELETE FROM
113117
groups
114118
WHERE
115119
id= $1;
116-
117-

‎coderd/provisionerdserver/provisionerdserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
491491
}
492492
ownerGroupNames:= []string{}
493493
for_,group:=rangeownerGroups {
494-
ownerGroupNames=append(ownerGroupNames,group.Name)
494+
ownerGroupNames=append(ownerGroupNames,group.Group.Name)
495495
}
496496
err=s.Pubsub.Publish(codersdk.WorkspaceNotifyChannel(workspace.ID), []byte{})
497497
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp