diff --git a/services/api/src/resources/openshift/resolvers.ts b/services/api/src/resources/openshift/resolvers.ts index db4276fae1..6e9aafc8c5 100644 --- a/services/api/src/resources/openshift/resolvers.ts +++ b/services/api/src/resources/openshift/resolvers.ts @@ -111,15 +111,21 @@ export const deleteOpenshift: ResolverFn = async ( export const getAllOpenshifts: ResolverFn = async ( root, - { disabled }, + { disabled, buildImage }, { sqlClientPool, hasPermission } ) => { await hasPermission('openshift', 'viewAll'); + let queryBuilder = knex('openshift'); + if (buildImage) { + queryBuilder = queryBuilder.and.whereNot('build_image', ''); + } + if (disabled != null) { - return query(sqlClientPool, knex('openshift').where('disabled', disabled).toString()); + queryBuilder = queryBuilder.where('disabled', disabled); } - return query(sqlClientPool, knex('openshift').toString()); + + return query(sqlClientPool, queryBuilder.toString()); }; export const getOpenshiftByProjectId: ResolverFn = async ( diff --git a/services/api/src/resources/project/resolvers.ts b/services/api/src/resources/project/resolvers.ts index 2c8c02ceb1..b55896c6fb 100644 --- a/services/api/src/resources/project/resolvers.ts +++ b/services/api/src/resources/project/resolvers.ts @@ -67,7 +67,7 @@ export const getProjectDeployKey: ResolverFn = async ( export const getAllProjects: ResolverFn = async ( root, - { order, createdAfter, gitUrl }, + { order, createdAfter, gitUrl, buildImage }, { sqlClientPool, hasPermission, models, keycloakGrant, keycloakUsersGroups } ) => { let userProjectIds: number[]; @@ -99,6 +99,10 @@ export const getAllProjects: ResolverFn = async ( queryBuilder = queryBuilder.andWhere('git_url', gitUrl); } + if (buildImage) { + queryBuilder = queryBuilder.and.whereNot('build_image', ''); + } + if (userProjectIds) { queryBuilder = queryBuilder.whereIn('id', userProjectIds); } diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 47f08cd0cd..1a1ed0922e 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1331,7 +1331,7 @@ const typeDefs = gql` """ Returns all Project Objects matching given filters (all if no filter defined) """ - allProjects(createdAfter: String, gitUrl: String, order: ProjectOrderType): [Project] + allProjects(createdAfter: String, gitUrl: String, order: ProjectOrderType, buildImage: Boolean): [Project] """ Returns all Project Objects matching metadata filters """ @@ -1339,11 +1339,11 @@ const typeDefs = gql` """ Returns all OpenShift Objects """ - allOpenshifts(disabled: Boolean): [Openshift] + allOpenshifts(disabled: Boolean, buildImage: Boolean): [Openshift] """ Returns all Kubernetes Objects """ - allKubernetes(disabled: Boolean): [Kubernetes] + allKubernetes(disabled: Boolean, buildImage: Boolean): [Kubernetes] """ Returns all Environments matching given filter (all if no filter defined) """