Skip to content

Commit

Permalink
feat: clone permissions and members for group creation (#443)
Browse files Browse the repository at this point in the history
* wip: clone permissions for group

Signed-off-by: Sarah Funkhouser <[email protected]>

* wip

Signed-off-by: Sarah Funkhouser <[email protected]>

* tests

Signed-off-by: Sarah Funkhouser <[email protected]>

* update test

Signed-off-by: Sarah Funkhouser <[email protected]>

* fixes

Signed-off-by: Sarah Funkhouser <[email protected]>

---------

Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade authored Feb 5, 2025
1 parent fac90dc commit d836330
Show file tree
Hide file tree
Showing 13 changed files with 948 additions and 8 deletions.
1 change: 1 addition & 0 deletions internal/ent/interceptors/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func filterType(ctx context.Context) string {
allowedCtx := []string{
"createGroup",
"updateGroup",
"createGroupByClone",
"createGroupWithMembers",
"createOrganizationWithMembers",
"createGroupMembership",
Expand Down
31 changes: 31 additions & 0 deletions internal/graphapi/clientschema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14345,6 +14345,32 @@ type Mutation {
members: [GroupMembersInput!]
): GroupCreatePayload!
"""
Create a new group with members
"""
createGroupByClone(
"""
values of the group
"""
groupInput: CreateGroupInput!

"""
group members to be added to the group
"""
members: [GroupMembersInput!]

"""
inheritGroupPermissions allows a group to be created with the same permissions
as the specified group ID
"""
inheritGroupPermissions: ID

"""
cloneGroupMembers allows a group to be created with the same group members
as the specified group ID
"""
cloneGroupMembers: ID
): GroupCreatePayload!
"""
Create a new groupMembership
"""
createGroupMembership(
Expand Down Expand Up @@ -30745,6 +30771,11 @@ input UpdateGroupInput {
addGroupMembers: [CreateGroupMembershipInput!]
removeGroupMembers: [ID!]
updateGroupSettings: UpdateGroupSettingInput
"""
inheritGroupPermissions allows a group to be updated with the same permissions
as the specified group ID, existing permissions will be removed
"""
inheritGroupPermissions: ID
}
"""
UpdateGroupMembershipInput is used for update GroupMembership object.
Expand Down
164 changes: 164 additions & 0 deletions internal/graphapi/generated/actionplan.generated.go

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

12 changes: 11 additions & 1 deletion internal/graphapi/generated/ent.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ type UpdateGroupInputResolver interface {
AddGroupMembers(ctx context.Context, obj *generated.UpdateGroupInput, data []*generated.CreateGroupMembershipInput) error
RemoveGroupMembers(ctx context.Context, obj *generated.UpdateGroupInput, data []string) error
UpdateGroupSettings(ctx context.Context, obj *generated.UpdateGroupInput, data *generated.UpdateGroupSettingInput) error
InheritGroupPermissions(ctx context.Context, obj *generated.UpdateGroupInput, data *string) error
}
type UpdateOrganizationInputResolver interface {
AddOrgMembers(ctx context.Context, obj *generated.UpdateOrganizationInput, data []*generated.CreateOrgMembershipInput) error
Expand Down Expand Up @@ -219808,7 +219809,7 @@ func (ec *executionContext) unmarshalInputUpdateGroupInput(ctx context.Context,
asMap[k] = v
}

fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "description", "clearDescription", "gravatarLogoURL", "clearGravatarLogoURL", "logoURL", "clearLogoURL", "displayName", "ownerID", "clearOwner", "addProcedureEditorIDs", "removeProcedureEditorIDs", "clearProcedureEditors", "addProcedureBlockedGroupIDs", "removeProcedureBlockedGroupIDs", "clearProcedureBlockedGroups", "addInternalPolicyEditorIDs", "removeInternalPolicyEditorIDs", "clearInternalPolicyEditors", "addInternalPolicyBlockedGroupIDs", "removeInternalPolicyBlockedGroupIDs", "clearInternalPolicyBlockedGroups", "addProgramEditorIDs", "removeProgramEditorIDs", "clearProgramEditors", "addProgramBlockedGroupIDs", "removeProgramBlockedGroupIDs", "clearProgramBlockedGroups", "addProgramViewerIDs", "removeProgramViewerIDs", "clearProgramViewers", "addRiskEditorIDs", "removeRiskEditorIDs", "clearRiskEditors", "addRiskBlockedGroupIDs", "removeRiskBlockedGroupIDs", "clearRiskBlockedGroups", "addRiskViewerIDs", "removeRiskViewerIDs", "clearRiskViewers", "addControlObjectiveEditorIDs", "removeControlObjectiveEditorIDs", "clearControlObjectiveEditors", "addControlObjectiveBlockedGroupIDs", "removeControlObjectiveBlockedGroupIDs", "clearControlObjectiveBlockedGroups", "addControlObjectiveViewerIDs", "removeControlObjectiveViewerIDs", "clearControlObjectiveViewers", "addControlEditorIDs", "removeControlEditorIDs", "clearControlEditors", "addControlBlockedGroupIDs", "removeControlBlockedGroupIDs", "clearControlBlockedGroups", "addControlViewerIDs", "removeControlViewerIDs", "clearControlViewers", "addNarrativeEditorIDs", "removeNarrativeEditorIDs", "clearNarrativeEditors", "addNarrativeBlockedGroupIDs", "removeNarrativeBlockedGroupIDs", "clearNarrativeBlockedGroups", "addNarrativeViewerIDs", "removeNarrativeViewerIDs", "clearNarrativeViewers", "settingID", "clearSetting", "addEventIDs", "removeEventIDs", "clearEvents", "addIntegrationIDs", "removeIntegrationIDs", "clearIntegrations", "addFileIDs", "removeFileIDs", "clearFiles", "addTaskIDs", "removeTaskIDs", "clearTasks", "addGroupMembers", "removeGroupMembers", "updateGroupSettings"}
fieldsInOrder := [...]string{"tags", "appendTags", "clearTags", "name", "description", "clearDescription", "gravatarLogoURL", "clearGravatarLogoURL", "logoURL", "clearLogoURL", "displayName", "ownerID", "clearOwner", "addProcedureEditorIDs", "removeProcedureEditorIDs", "clearProcedureEditors", "addProcedureBlockedGroupIDs", "removeProcedureBlockedGroupIDs", "clearProcedureBlockedGroups", "addInternalPolicyEditorIDs", "removeInternalPolicyEditorIDs", "clearInternalPolicyEditors", "addInternalPolicyBlockedGroupIDs", "removeInternalPolicyBlockedGroupIDs", "clearInternalPolicyBlockedGroups", "addProgramEditorIDs", "removeProgramEditorIDs", "clearProgramEditors", "addProgramBlockedGroupIDs", "removeProgramBlockedGroupIDs", "clearProgramBlockedGroups", "addProgramViewerIDs", "removeProgramViewerIDs", "clearProgramViewers", "addRiskEditorIDs", "removeRiskEditorIDs", "clearRiskEditors", "addRiskBlockedGroupIDs", "removeRiskBlockedGroupIDs", "clearRiskBlockedGroups", "addRiskViewerIDs", "removeRiskViewerIDs", "clearRiskViewers", "addControlObjectiveEditorIDs", "removeControlObjectiveEditorIDs", "clearControlObjectiveEditors", "addControlObjectiveBlockedGroupIDs", "removeControlObjectiveBlockedGroupIDs", "clearControlObjectiveBlockedGroups", "addControlObjectiveViewerIDs", "removeControlObjectiveViewerIDs", "clearControlObjectiveViewers", "addControlEditorIDs", "removeControlEditorIDs", "clearControlEditors", "addControlBlockedGroupIDs", "removeControlBlockedGroupIDs", "clearControlBlockedGroups", "addControlViewerIDs", "removeControlViewerIDs", "clearControlViewers", "addNarrativeEditorIDs", "removeNarrativeEditorIDs", "clearNarrativeEditors", "addNarrativeBlockedGroupIDs", "removeNarrativeBlockedGroupIDs", "clearNarrativeBlockedGroups", "addNarrativeViewerIDs", "removeNarrativeViewerIDs", "clearNarrativeViewers", "settingID", "clearSetting", "addEventIDs", "removeEventIDs", "clearEvents", "addIntegrationIDs", "removeIntegrationIDs", "clearIntegrations", "addFileIDs", "removeFileIDs", "clearFiles", "addTaskIDs", "removeTaskIDs", "clearTasks", "addGroupMembers", "removeGroupMembers", "updateGroupSettings", "inheritGroupPermissions"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
Expand Down Expand Up @@ -220430,6 +220431,15 @@ func (ec *executionContext) unmarshalInputUpdateGroupInput(ctx context.Context,
if err = ec.resolvers.UpdateGroupInput().UpdateGroupSettings(ctx, &it, data); err != nil {
return it, err
}
case "inheritGroupPermissions":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inheritGroupPermissions"))
data, err := ec.unmarshalOID2ᚖstring(ctx, v)
if err != nil {
return it, err
}
if err = ec.resolvers.UpdateGroupInput().InheritGroupPermissions(ctx, &it, data); err != nil {
return it, err
}
}
}

Expand Down
43 changes: 43 additions & 0 deletions internal/graphapi/generated/root_.generated.go

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

Loading

0 comments on commit d836330

Please sign in to comment.