Skip to content

Commit 479c1c3

Browse files
authored
feat(rbac): add ParentId to project membership response (#2292)
Signed-off-by: Jose I. Paris <[email protected]>
1 parent 1f9be4b commit 479c1c3

File tree

8 files changed

+57
-7
lines changed

8 files changed

+57
-7
lines changed

app/controlplane/api/controlplane/v1/project.pb.go

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/controlplane/v1/project.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ message ProjectMember {
6868
google.protobuf.Timestamp updated_at = 5;
6969
// The ID of latest project version this member is associated with
7070
string latest_project_version_id = 6;
71+
// Optional parent ID for nested project memberships
72+
optional string parent_id = 7;
7173
}
7274

7375
// ProjectServiceAddMemberRequest contains the information needed to add a user to a project

app/controlplane/api/gen/frontend/controlplane/v1/project.ts

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

app/controlplane/api/gen/jsonschema/controlplane.v1.ProjectMember.jsonschema.json

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

app/controlplane/api/gen/jsonschema/controlplane.v1.ProjectMember.schema.json

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

app/controlplane/internal/service/project.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,16 @@ func mapProjectMemberRoleToAuthzRole(role pb.ProjectMemberRole) authz.Role {
382382

383383
// bizProjectMembershipToPb converts a biz.ProjectMembership to a pb.ProjectMember
384384
func bizProjectMembershipToPb(m *biz.ProjectMembership) *pb.ProjectMember {
385-
var role pb.ProjectMemberRole
386-
387-
// Map the role string back to a protobuf enum
388-
role = mapAuthzRoleToProjectMemberRole(m.Role)
385+
role := mapAuthzRoleToProjectMemberRole(m.Role)
389386

390387
pbMember := &pb.ProjectMember{
391388
Role: role,
392389
}
393390

391+
if m.ParentID != nil {
392+
pbMember.ParentId = biz.ToPtr(m.ParentID.String())
393+
}
394+
394395
if m.User != nil {
395396
pbMember.Subject = &pb.ProjectMember_User{
396397
User: bizUserToPb(m.User),

app/controlplane/pkg/biz/project.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ type ProjectMembership struct {
9494
CreatedAt *time.Time
9595
// UpdatedAt is the timestamp when the membership was last updated.
9696
UpdatedAt *time.Time
97+
// ParentID is used for nested memberships, if applicable
98+
ParentID *uuid.UUID
9799
}
98100

99101
// GroupProjectInfo represents detailed information about a project that a group is a member of

app/controlplane/pkg/data/project.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ func entProjectMembershipToBiz(m *ent.Membership, u *ent.User, g *ent.Group) *bi
359359
Role: m.Role,
360360
CreatedAt: &m.CreatedAt,
361361
UpdatedAt: &m.UpdatedAt,
362+
ParentID: m.ParentID,
362363
}
363364

364365
if u != nil {

0 commit comments

Comments
 (0)