From f294640f8a1af3919d6bf560ec706ab52dbf0487 Mon Sep 17 00:00:00 2001 From: Leonard Bogdonoff Date: Thu, 17 Aug 2017 18:13:42 -0400 Subject: [PATCH 1/4] Create the response for when multiple param needing services are rendered --- .../components/create_service_instance.jsx | 113 +++++++++++------- 1 file changed, 73 insertions(+), 40 deletions(-) diff --git a/static_src/components/create_service_instance.jsx b/static_src/components/create_service_instance.jsx index 94afa20f..d77b718d 100644 --- a/static_src/components/create_service_instance.jsx +++ b/static_src/components/create_service_instance.jsx @@ -16,6 +16,11 @@ import formActions from '../actions/form_actions'; import { validateString } from '../util/validators'; const CREATE_SERVICE_INSTANCE_FORM_GUID = 'create-service-form'; +const CF_CLI_SERVICE_DETAILS = { + 'cdn-route': 'https://cloud.gov/docs/services/cdn-route/', + 'cloud-gov-identity-provider': 'https://cloud.gov/docs/services/cloud-gov-identity-provider/', + 'cloud-gov-service-account': 'https://cloud.gov/docs/services/cloud-gov-service-account/' +}; const propTypes = { error: PropTypes.object, @@ -90,6 +95,73 @@ export default class CreateServiceInstance extends React.Component { serviceActions.createInstanceFormCancel(); } + get formContent() { + const serviceName = this.serviceName; + if (CF_CLI_SERVICE_DETAILS.hasOwnProperty(serviceName)) { + return ( +
+ + The + + { serviceName } + service instance must be created using the CF CLI. + Please refer to { CF_CLI_SERVICE_DETAILS[serviceName] } for more + information. + +
+ ); + } else { + return ( +
+ + Create a service instance for + + { this.serviceName } + using + + { this.servicePlanName } + plan. + + + + { this.contextualAction } + + Cancel + + + ); + } + } + get serviceName() { return this.props.service.label || 'Unknown Service Name'; } @@ -139,46 +211,7 @@ export default class CreateServiceInstance extends React.Component { return (
{ createError } -
- - Create a service instance for - - { this.serviceName } - using - - { this.servicePlanName } - plan. - - - - { this.contextualAction } - - Cancel - - + { this.formContent }
); } From 46d775ce648257fea3962de412493a3716fefa3e Mon Sep 17 00:00:00 2001 From: Leonard Bogdonoff Date: Fri, 18 Aug 2017 14:51:40 -0400 Subject: [PATCH 2/4] Create tests for the various create service instance conditions with hardcoded responses --- .../create_service_instance.spec.jsx | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/static_src/test/unit/components/create_service_instance.spec.jsx b/static_src/test/unit/components/create_service_instance.spec.jsx index c9027593..b3fba3c8 100644 --- a/static_src/test/unit/components/create_service_instance.spec.jsx +++ b/static_src/test/unit/components/create_service_instance.spec.jsx @@ -7,6 +7,14 @@ import serviceActions from '../../../actions/service_actions'; import { shallow } from 'enzyme'; describe('', () => { + + const serviceProps = { + service: {}, + servicePlan: { + guid: 'some-plan-guid' + } + }; + it('displays an error message when ServiceInstanceStore has one', () => { const error = { description: 'Bad stuff everyone' }; const wrapper = shallow(); @@ -32,4 +40,53 @@ describe('', () => { expect(typeof spy.getCall(0).args[0]).toBe('string'); }); }); + + describe('when serviceAction.createInstance has pre-designated responses', () => { + it('called for cdn-route', () => { + const serviceInstanceHTML = '
' + + 'Thecdn-route service instance ' + + 'must be created using the CF CLI. Please refer to https://cloud.gov/docs/services/cdn-route/ ' + + 'for more information.
'; + const serviceProps = Object.assign({}, serviceProps, { + service: { label: 'cdn-route' } + }); + const wrapper = shallow(); + + expect(wrapper.html()).toEqual(serviceInstanceHTML); + }); + + it('called for cloud-gov-identity-provider', () => { + const serviceInstanceHTML = '
' + + 'Thecloud-gov-identity-provider ' + + 'service instance must be created using the CF CLI. Please refer to https://clo' + + 'ud.gov/docs/services/cloud-gov-identity-provider/ for more information.' + + '
'; + const serviceProps = Object.assign({}, serviceProps, { + service: { label: 'cloud-gov-identity-provider' } + }); + const wrapper = shallow(); + + expect(wrapper.html()).toEqual(serviceInstanceHTML); + }); + + it('called for cloud-gov-service-account', () => { + const serviceInstanceHTML = '
' + + 'Thecloud-gov-service-account ' + + 'service instance must be created using the CF CLI. Please refer to https://' + + 'cloud.gov/docs/services/cloud-gov-service-account/ for more information.' + + '
'; + const serviceProps = Object.assign({}, serviceProps, { + service: { label: 'cloud-gov-service-account' } + }); + const wrapper = shallow(); + + expect(wrapper.html()).toEqual(serviceInstanceHTML); + }); + }); }); From de3f7353dd7dcc5146a2abab499873d98f693cf8 Mon Sep 17 00:00:00 2001 From: Leonard Bogdonoff Date: Fri, 18 Aug 2017 15:06:30 -0400 Subject: [PATCH 3/4] Create comment --- static_src/components/create_service_instance.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static_src/components/create_service_instance.jsx b/static_src/components/create_service_instance.jsx index d77b718d..83b6f949 100644 --- a/static_src/components/create_service_instance.jsx +++ b/static_src/components/create_service_instance.jsx @@ -16,6 +16,10 @@ import formActions from '../actions/form_actions'; import { validateString } from '../util/validators'; const CREATE_SERVICE_INSTANCE_FORM_GUID = 'create-service-form'; + +// Note: +// This is a temporary hardcoded solution to resolve the need +// for multiple parameters when setting up service instances. const CF_CLI_SERVICE_DETAILS = { 'cdn-route': 'https://cloud.gov/docs/services/cdn-route/', 'cloud-gov-identity-provider': 'https://cloud.gov/docs/services/cloud-gov-identity-provider/', From cc2d78103b242c010581015bff315441f0c81b9b Mon Sep 17 00:00:00 2001 From: Leonard Bogdonoff Date: Fri, 18 Aug 2017 15:11:36 -0400 Subject: [PATCH 4/4] Lint fix --- .../unit/components/create_service_instance.spec.jsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/static_src/test/unit/components/create_service_instance.spec.jsx b/static_src/test/unit/components/create_service_instance.spec.jsx index b3fba3c8..2a82490e 100644 --- a/static_src/test/unit/components/create_service_instance.spec.jsx +++ b/static_src/test/unit/components/create_service_instance.spec.jsx @@ -7,8 +7,7 @@ import serviceActions from '../../../actions/service_actions'; import { shallow } from 'enzyme'; describe('', () => { - - const serviceProps = { + const serviceBaseProps = { service: {}, servicePlan: { guid: 'some-plan-guid' @@ -49,7 +48,7 @@ describe('', () => { 'must be created using the CF CLI. Please refer to https://cloud.gov/docs/services/cdn-route/ ' + 'for more information.'; - const serviceProps = Object.assign({}, serviceProps, { + const serviceProps = Object.assign({}, serviceBaseProps, { service: { label: 'cdn-route' } }); const wrapper = shallow(); @@ -65,7 +64,7 @@ describe('', () => { '//cloud.gov/docs/services/cloud-gov-identity-provider/" target="_blank">https://clo' + 'ud.gov/docs/services/cloud-gov-identity-provider/ for more information.' + ''; - const serviceProps = Object.assign({}, serviceProps, { + const serviceProps = Object.assign({}, serviceBaseProps, { service: { label: 'cloud-gov-identity-provider' } }); const wrapper = shallow(); @@ -81,7 +80,7 @@ describe('', () => { 'https://cloud.gov/docs/services/cloud-gov-service-account/" target="_blank">https://' + 'cloud.gov/docs/services/cloud-gov-service-account/ for more information.' + ''; - const serviceProps = Object.assign({}, serviceProps, { + const serviceProps = Object.assign({}, serviceBaseProps, { service: { label: 'cloud-gov-service-account' } }); const wrapper = shallow();