diff --git a/services/api/src/apolloServer.js b/services/api/src/apolloServer.js
index 9aa9f2088e..18bd1f8a3c 100644
--- a/services/api/src/apolloServer.js
+++ b/services/api/src/apolloServer.js
@@ -191,6 +191,26 @@ const apolloServer = new ApolloServer({
};
},
plugins: [
+ // Debug plugin for logging resolver execution order
+ // {
+ // requestDidStart(initialRequestContext) {
+ // return {
+ // executionDidStart(executionRequestContext) {
+ // return {
+ // willResolveField({source, args, context, info}) {
+ // console.log(`Resolving ${info.parentType.name}.${info.fieldName}`);
+ // const start = process.hrtime.bigint();
+ // return (error, result) => {
+ // const end = process.hrtime.bigint();
+ // // Uncomment to log resolver execution time
+ // // console.log(`Field ${info.parentType.name}.${info.fieldName} took ${end - start}ns`);
+ // };
+ // }
+ // }
+ // }
+ // }
+ // }
+ // },
{
requestDidStart: () => ({
willSendResponse: response => {
diff --git a/services/api/src/resolvers.js b/services/api/src/resolvers.js
index 14ed9033f1..f13a72ccf1 100644
--- a/services/api/src/resolvers.js
+++ b/services/api/src/resolvers.js
@@ -161,6 +161,9 @@ const {
getProjectUser,
updateOpenshift,
deleteAllOpenshifts,
+ getToken,
+ getConsoleUrl,
+ getMonitoringConfig,
} = require('./resources/openshift/resolvers');
const {
@@ -319,9 +322,15 @@ const resolvers = {
},
Openshift: {
projectUser: getProjectUser,
+ token: getToken,
+ consoleUrl: getConsoleUrl,
+ monitoringConfig: getMonitoringConfig,
},
Kubernetes: {
projectUser: getProjectUser,
+ token: getToken,
+ consoleUrl: getConsoleUrl,
+ monitoringConfig: getMonitoringConfig,
},
Project: {
notifications: getNotificationsByProjectId,
diff --git a/services/api/src/resources/openshift/resolvers.ts b/services/api/src/resources/openshift/resolvers.ts
index 8f00400e30..1ae1edeb48 100644
--- a/services/api/src/resources/openshift/resolvers.ts
+++ b/services/api/src/resources/openshift/resolvers.ts
@@ -2,15 +2,47 @@ import * as R from 'ramda';
import { ResolverFn } from '../';
import { query, isPatchEmpty, knex } from '../../util/db';
import { Helpers as projectHelpers } from '../project/helpers';
-import sql from '../user/sql';
import { Sql } from './sql';
-const attrFilter = async (hasPermission, entity) => {
+export const getToken: ResolverFn = async (
+ kubernetes,
+ _args,
+ { hasPermission }
+) => {
+ try {
+ await hasPermission('openshift', 'view:token');
+
+ return kubernetes.token;
+ } catch (err) {
+ return null;
+ }
+};
+
+export const getConsoleUrl: ResolverFn = async (
+ kubernetes,
+ _args,
+ { hasPermission }
+) => {
try {
await hasPermission('openshift', 'view:token');
- return entity;
+
+ return kubernetes.consoleUrl;
+ } catch (err) {
+ return null;
+ }
+};
+
+export const getMonitoringConfig: ResolverFn = async (
+ kubernetes,
+ _args,
+ { hasPermission }
+) => {
+ try {
+ await hasPermission('openshift', 'view:token');
+
+ return kubernetes.monitoringConfig;
} catch (err) {
- return R.omit(['token','consoleUrl','monitoringConfig'], entity);
+ return null;
}
};
@@ -82,7 +114,7 @@ export const getOpenshiftByProjectId: ResolverFn = async (
}
);
- return rows ? attrFilter(hasPermission, rows[0]) : null;
+ return rows ? rows[0] : null;
};
export const getOpenshiftByDeployTargetId: ResolverFn = async (
@@ -119,7 +151,7 @@ export const getOpenshiftByDeployTargetId: ResolverFn = async (
}
);
- return rows ? attrFilter(hasPermission, rows[0]) : null;
+ return rows ? rows[0] : null;
};
export const getOpenshiftByEnvironmentId: ResolverFn = async (
@@ -149,7 +181,7 @@ export const getOpenshiftByEnvironmentId: ResolverFn = async (
}
);
- return rows ? attrFilter(hasPermission, rows[0]) : null;
+ return rows ? rows[0] : null;
};
export const updateOpenshift: ResolverFn = async (
diff --git a/services/ui/src/components/Environments/index.js b/services/ui/src/components/Environments/index.js
index b7286f4693..78ca06d28f 100644
--- a/services/ui/src/components/Environments/index.js
+++ b/services/ui/src/components/Environments/index.js
@@ -34,7 +34,7 @@ const { className: boxClassName, styles: boxStyles } = css.resolve`
}
`;
-const Environments = ({ environments = [] }) => {
+const Environments = ({ environments = [], project }) => {
if (environments.length === 0) {
return null;
}
@@ -61,7 +61,7 @@ const Environments = ({ environments = [] }) => {
{environment.environmentType == 'production' && (
@@ -69,12 +69,12 @@ const Environments = ({ environments = [] }) => {
Production
)}
- {environment.project.productionEnvironment && environment.project.standbyProductionEnvironment && environment.project.productionEnvironment == environment.name && (
+ {project.productionEnvironment && project.standbyProductionEnvironment && project.productionEnvironment == environment.name && (
Active
)}
- {environment.project.productionEnvironment && environment.project.standbyProductionEnvironment && environment.project.standbyProductionEnvironment == environment.name && (
+ {project.productionEnvironment && project.standbyProductionEnvironment && project.standbyProductionEnvironment == environment.name && (
Standby
diff --git a/services/ui/src/components/ProjectDetailsSidebar/index.js b/services/ui/src/components/ProjectDetailsSidebar/index.js
index 01a72f44fb..8a7b47065a 100644
--- a/services/ui/src/components/ProjectDetailsSidebar/index.js
+++ b/services/ui/src/components/ProjectDetailsSidebar/index.js
@@ -6,10 +6,6 @@ import giturlparse from 'git-url-parse';
import Environments from 'components/Environments';
import { bp, color, fontSize } from 'lib/variables';
-import { Mutation } from 'react-apollo';
-
-import ProjectByNameQuery from 'lib/query/ProjectByName';
-
const Project = ({ project }) => {
const [copied, setCopied] = useState(false);
const gitUrlParsed = giturlparse(project.gitUrl);
@@ -18,6 +14,7 @@ const Project = ({ project }) => {
project.environments
);
const developEnvironmentCount = R.propOr(0, 'development', environmentCount);
+ const projectUsesDeployTargets = project.deployTargetConfigs.length > 0;
return (
@@ -69,7 +66,7 @@ const Project = ({ project }) => {
- {project.deployTargetConfigs.length === 0 && (
+ {!projectUsesDeployTargets && (
@@ -77,7 +74,7 @@ const Project = ({ project }) => {
)}
- {project.deployTargetConfigs.length === 0 && (
+ {!projectUsesDeployTargets === 0 && (
@@ -94,16 +91,16 @@ const Project = ({ project }) => {
- {project.deployTargetConfigs.length > 0 && (
+ {projectUsesDeployTargets && (
{project.deployTargetConfigs.map(depTarget => (
-
+
+ : depTarget.deployTarget.name}
{depTarget.branches}
diff --git a/services/ui/src/lib/query/AllAdvancedTasksForEnvironment.js b/services/ui/src/lib/query/AllAdvancedTasksForEnvironment.js
deleted file mode 100644
index 70d176d594..0000000000
--- a/services/ui/src/lib/query/AllAdvancedTasksForEnvironment.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import gql from 'graphql-tag';
-
-export default gql`
- query advancedTasksForEnvironment(environment: Int!) {
- task_definitions: advancedTasksForEnvironment(environment: $environment) {
- ... on AdvancedTaskDefinitionImage {
- id
- type
- name
- description
- environment
- project
- service
- created
- deleted
- confirmationText
- advancedTaskDefinitionArguments {
- id
- name
- displayName
- type
- range
- }
- }
- ... on AdvancedTaskDefinitionCommand {
- id
- type
- name
- description
- environment
- project
- service
- created
- deleted
- confirmationText
- advancedTaskDefinitionArguments {
- id
- name
- displayName
- type
- range
- }
- }
- }
- }
-`;
diff --git a/services/ui/src/lib/query/AllProjectsAfterDate.js b/services/ui/src/lib/query/AllProjectsAfterDate.js
deleted file mode 100644
index a2ae1cb49e..0000000000
--- a/services/ui/src/lib/query/AllProjectsAfterDate.js
+++ /dev/null
@@ -1,21 +0,0 @@
-import gql from 'graphql-tag';
-
-export default gql`
- query allProjectAfterDate($createdAfter: String){
- allProjects(createdAfter: $createdAfter) {
- id
- name
- created
- availability
- # groups {
- # __typename
- # name
- # type
- # }
- environments(includeDeleted: true) {
- id
- name
- }
- }
- }
-`;
\ No newline at end of file
diff --git a/services/ui/src/lib/query/AllProjectsAndEnvironments.js b/services/ui/src/lib/query/AllProjectsAndEnvironments.js
deleted file mode 100644
index ea2a6f79e3..0000000000
--- a/services/ui/src/lib/query/AllProjectsAndEnvironments.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import gql from 'graphql-tag';
-
-export default gql`{
- projects: allProjects {
- id
- name
- environments(type: PRODUCTION) {
- id
- name
- openshiftProjectName
- }
- }
-}
-`;
diff --git a/services/ui/src/lib/query/EnvironmentByOpenshiftProjectName.js b/services/ui/src/lib/query/EnvironmentByOpenshiftProjectName.js
index 5f505db518..5dcc4b5949 100644
--- a/services/ui/src/lib/query/EnvironmentByOpenshiftProjectName.js
+++ b/services/ui/src/lib/query/EnvironmentByOpenshiftProjectName.js
@@ -13,11 +13,6 @@ export default gql`
environmentType
routes
openshiftProjectName
- openshift {
- friendlyName
- cloudProvider
- cloudRegion
- }
project {
name
gitUrl
diff --git a/services/ui/src/lib/query/GroupByName.js b/services/ui/src/lib/query/GroupByName.js
deleted file mode 100644
index a69c358be5..0000000000
--- a/services/ui/src/lib/query/GroupByName.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import gql from 'graphql-tag';
-
-export default gql`
- query groupByName($name:String!){
- groupByName(name: $name){
- id,
- name,
- projects {
- id
- name
- availability
- }
- }
- }
-`;
diff --git a/services/ui/src/lib/query/ProjectByEnvironmentId.js b/services/ui/src/lib/query/ProjectByEnvironmentId.js
deleted file mode 100644
index 4d376f8fbc..0000000000
--- a/services/ui/src/lib/query/ProjectByEnvironmentId.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import gql from 'graphql-tag';
-
-export default gql`
- query getProjectByEnvironmentId($id: Int!) {
- environment: environmentById(id: $id) {
- id
- name
- project {
- name
- openshift {
- name
- }
- gitUrl
- }
- }
- }
-`;
diff --git a/services/ui/src/lib/query/ProjectByName.js b/services/ui/src/lib/query/ProjectByName.js
index dddcc67a61..fe29e2b9e0 100644
--- a/services/ui/src/lib/query/ProjectByName.js
+++ b/services/ui/src/lib/query/ProjectByName.js
@@ -12,40 +12,26 @@ export default gql`
productionEnvironment
standbyProductionEnvironment
developmentEnvironmentsLimit
- deployTargetConfigs{
+ deployTargetConfigs {
id
branches
pullrequests
- weight
- deployTarget{
+ deployTarget {
id
name
friendlyName
- cloudProvider
- cloudRegion
}
}
environments {
id
name
- created
- updated
deployType
environmentType
openshiftProjectName
openshift {
friendlyName
- cloudProvider
cloudRegion
}
- project {
- id
- name
- productionEnvironment
- standbyProductionEnvironment
- problemsUi
- factsUi
- }
}
}
}
diff --git a/services/ui/src/lib/query/ProjectGroupsByProjectName.js b/services/ui/src/lib/query/ProjectGroupsByProjectName.js
deleted file mode 100644
index 6053a63c63..0000000000
--- a/services/ui/src/lib/query/ProjectGroupsByProjectName.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import gql from 'graphql-tag';
-
-export default gql`
- query getProject($name: String!){
- project: projectByName (name: $name){
- id
- name
- branches
- pullrequests
- created
- gitUrl
- productionEnvironment
- standbyProductionEnvironment
- developmentEnvironmentsLimit
- environments {
- id
- name
- created
- updated
- deployType
- environmentType
- openshiftProjectName
- }
- availability
- groups{
- id
- name
- type
- }
- }
- }
-`;
\ No newline at end of file
diff --git a/services/ui/src/pages/project.js b/services/ui/src/pages/project.js
index 3ba269414e..292af13f4f 100644
--- a/services/ui/src/pages/project.js
+++ b/services/ui/src/pages/project.js
@@ -52,7 +52,7 @@ export const PageProject = ({ router }) => (
Environments
{!environments.length &&
No Environments
}
-
+