From 2cc98ab6c6b1ce7a4d83c9c396f14232caa78e19 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Mon, 9 Oct 2023 10:44:41 +1100 Subject: [PATCH 1/5] Updated group orgs --- .../api-data/04-populate-api-data-organizations.gql | 2 +- services/api/src/typeDefs.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/local-dev/api-data-watcher-pusher/api-data/04-populate-api-data-organizations.gql b/local-dev/api-data-watcher-pusher/api-data/04-populate-api-data-organizations.gql index 3d45db9137..69c5126291 100644 --- a/local-dev/api-data-watcher-pusher/api-data/04-populate-api-data-organizations.gql +++ b/local-dev/api-data-watcher-pusher/api-data/04-populate-api-data-organizations.gql @@ -44,7 +44,7 @@ mutation PopulateApi { id } - UIOrganizationGroup: addGroup( + UIOrganizationGroup: addGroupToOrganization( input: { name: "organization-group1", organization: 1} ) { id diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 633b887e51..02c7c8cc9a 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1077,7 +1077,7 @@ const typeDefs = gql` deployTargets: [Openshift] projects: [OrgProject] environments: [OrgEnvironment] - groups: [GroupInterface] + groups: [OrgGroupInterface] owners: [OrgUser] notifications(type: NotificationType): [Notification] } @@ -1121,7 +1121,7 @@ const typeDefs = gql` id: Int name: String organization: Int - groups: [GroupInterface] + groups: [OrgGroupInterface] groupCount: Int notifications: [OrganizationNotification] } @@ -2175,7 +2175,12 @@ const typeDefs = gql` input AddGroupInput { name: String! parentGroup: GroupInput - organization: Int + } + + input AddGroupToOrganizationInput { + name: String! + organization: Int! + parentGroup: GroupInput addOrgOwner: Boolean } @@ -2419,7 +2424,7 @@ const typeDefs = gql` """ Add a group to an organization """ - addGroupToOrganization(input: AddGroupInput!): GroupInterface + addGroupToOrganization(input: AddGroupToOrganizationInput!): OrgGroupInterface """ Add a project to an organization, will return an error if it can't easily do it """ From 70ccfe6493159cfc3209c48eabf55df26f546415 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Tue, 10 Oct 2023 16:45:29 +1100 Subject: [PATCH 2/5] Updated resolver --- services/api/src/resolvers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/api/src/resolvers.js b/services/api/src/resolvers.js index 674add53ff..a14d7568c0 100644 --- a/services/api/src/resolvers.js +++ b/services/api/src/resolvers.js @@ -704,7 +704,7 @@ const resolvers = { addOrganization, updateOrganization, deleteOrganization, - addGroupToOrganization, + addGroupToOrganization: addGroup, addProjectToOrganization, removeProjectFromOrganization, addDeployTargetToOrganization, From c3f1fa31b15af49ce8284fa4e2e15e49ceb947c2 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Tue, 10 Oct 2023 17:25:42 +1100 Subject: [PATCH 3/5] Renamed existing resolver --- services/api/src/resolvers.js | 3 ++- services/api/src/resources/organization/resolvers.ts | 2 +- services/api/src/typeDefs.js | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/api/src/resolvers.js b/services/api/src/resolvers.js index a14d7568c0..ebc8963a65 100644 --- a/services/api/src/resolvers.js +++ b/services/api/src/resolvers.js @@ -260,7 +260,7 @@ const { getProjectsByOrganizationId, addProjectToOrganization, removeProjectFromOrganization, - addGroupToOrganization, + addExistingGroupToOrganization, getGroupsByOrganizationsProject, getGroupCountByOrganizationProject, getProjectGroupOrganizationAssociation, // WIP resolver @@ -705,6 +705,7 @@ const resolvers = { updateOrganization, deleteOrganization, addGroupToOrganization: addGroup, + addExistingGroupToOrganization, addProjectToOrganization, removeProjectFromOrganization, addDeployTargetToOrganization, diff --git a/services/api/src/resources/organization/resolvers.ts b/services/api/src/resources/organization/resolvers.ts index 67d9b0b4e0..0954a06e38 100644 --- a/services/api/src/resources/organization/resolvers.ts +++ b/services/api/src/resources/organization/resolvers.ts @@ -842,7 +842,7 @@ export const getGroupProjectOrganizationAssociation: ResolverFn = async ( // add an existing group to an organization // this function will return errors if there are projects in the group that are not in the organization // if there are no projects in the organization, and no projects in the group then it will succeed -export const addGroupToOrganization: ResolverFn = async ( +export const addExistingGroupToOrganization: ResolverFn = async ( _root, { input }, { models, sqlClientPool, hasPermission, userActivityLogger } diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 02c7c8cc9a..3832f5a07b 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -2426,6 +2426,10 @@ const typeDefs = gql` """ addGroupToOrganization(input: AddGroupToOrganizationInput!): OrgGroupInterface """ + Add an existing group to an organization + """ + addExistingGroupToOrganization(input: AddGroupToOrganizationInput!): OrgGroupInterface + """ Add a project to an organization, will return an error if it can't easily do it """ addProjectToOrganization(input: AddProjectToOrganizationInput): Project From bbbb3b88e59e7b0447f152a0f6eedfd95bd8c7fb Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 11 Oct 2023 10:28:58 +1100 Subject: [PATCH 4/5] Updated getGroupProjectOrganizationAssociation input --- services/api/src/typeDefs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 3832f5a07b..61e51f8bb9 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1416,7 +1416,7 @@ const typeDefs = gql` Get an organization by its ID """ organizationById(organization: Int!): Organization - getGroupProjectOrganizationAssociation(input: AddGroupInput!): String + getGroupProjectOrganizationAssociation(input: AddGroupToOrganizationInput!): String getProjectGroupOrganizationAssociation(input: ProjectOrgGroupsInput!): String getEnvVariablesByProjectEnvironmentName(input: EnvVariableByProjectEnvironmentNameInput!): [EnvKeyValue] } From 9a3b07399ebc5e986fec63d3640fa74de3bf54de Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 11 Oct 2023 10:52:18 +1100 Subject: [PATCH 5/5] Fixed incorrect arg --- services/api/src/typeDefs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 5ba7036a06..c54805b1ee 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1415,7 +1415,7 @@ const typeDefs = gql` """ Get an organization by its ID """ - organizationById(organization: Int!): Organization + organizationById(id: Int!): Organization organizationByName(name: String!): Organization getGroupProjectOrganizationAssociation(input: AddGroupToOrganizationInput!): String getProjectGroupOrganizationAssociation(input: ProjectOrgGroupsInput!): String