Skip to content

Commit a67c1f1

Browse files
committed
Merge branch 'multi-container' of github.com:awslabs/aws-saas-boost into multi-container
2 parents 25837d7 + e6306bb commit a67c1f1

File tree

4 files changed

+104
-96
lines changed

4 files changed

+104
-96
lines changed

client/web/.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false,
4+
"semi": false,
5+
"singleQuote": true,
6+
"trailingComma": "es5",
7+
"printWidth": 80
8+
}

client/web/src/onboarding/OnboardingCreateContainer.js

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@ import React, { useEffect, useState } from 'react'
1818
import { useHistory } from 'react-router-dom'
1919

2020
import OnboardingFormComponent from './OnboardingFormComponent'
21-
import { createOnboarding, selectLoading, selectError, selectErrorName } from './ducks'
21+
import {
22+
createOnboarding,
23+
selectLoading,
24+
selectError,
25+
selectErrorName,
26+
} from './ducks'
2227
import { useDispatch, useSelector } from 'react-redux'
2328
import { selectConfig, fetchConfig } from '../settings/ducks'
24-
import { fetchPlans, selectAllPlans, selectPlanLoading, selectPlanError } from '../billing/ducks'
29+
import {
30+
fetchPlans,
31+
selectAllPlans,
32+
selectPlanLoading,
33+
selectPlanError,
34+
} from '../billing/ducks'
2535
import { saveToPresignedBucket } from '../settings/ducks'
2636
export default function OnboardingCreateContainer(props) {
2737
const dispatch = useDispatch()
@@ -47,23 +57,31 @@ export default function OnboardingCreateContainer(props) {
4757
const fetchConfigResponse = dispatch(fetchConfig())
4858
}, [dispatch])
4959

50-
const submitOnboardingRequestForm = async (values, { resetForm, setSubmitting }) => {
51-
const { overrideDefaults, hasDomain, computeSize, minCount, maxCount, ...rest } = values
52-
let onboardingResponse
53-
const valsToSend = overrideDefaults
54-
? {
55-
...rest,
56-
computeSize,
57-
minCount,
58-
maxCount,
59-
}
60-
: { ...rest }
60+
const nullBlankProps = (obj) => {
61+
const ret = { ...obj }
62+
Object.keys(ret).forEach((key) => {
63+
const val = ret[key]
64+
if (val !== null && !val) {
65+
ret[key] = null
66+
}
67+
})
68+
return ret
69+
}
6170

71+
const submitOnboardingRequestForm = async (
72+
values,
73+
{ resetForm, setSubmitting }
74+
) => {
75+
const { hasDomain, hasBilling, ...rest } = values
76+
const valsToSend = nullBlankProps(rest)
77+
let onboardingResponse
6278
try {
6379
onboardingResponse = await dispatch(createOnboarding(valsToSend))
6480
const presignedS3url = onboardingResponse.payload.zipFileUrl
6581
if (presignedS3url && !!file && file.name) {
66-
await dispatch(saveToPresignedBucket({ dbFile: file, url: presignedS3url }))
82+
await dispatch(
83+
saveToPresignedBucket({ dbFile: file, url: presignedS3url })
84+
)
6785
}
6886
history.push(`/onboarding/${onboardingResponse.payload.id}`)
6987
} catch (err) {

client/web/src/onboarding/OnboardingFormComponent.js

Lines changed: 51 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ import { PropTypes } from 'prop-types'
1717
import React from 'react'
1818
import { Formik, Form } from 'formik'
1919
import * as Yup from 'yup'
20-
import { Row, Col, Card, Button, CardHeader, CardBody, CardFooter, Alert } from 'reactstrap'
20+
import {
21+
Row,
22+
Col,
23+
Card,
24+
Button,
25+
CardHeader,
26+
CardBody,
27+
CardFooter,
28+
Alert,
29+
} from 'reactstrap'
2130
import {
2231
SaasBoostInput,
2332
SaasBoostSelect,
@@ -52,20 +61,17 @@ OnboardingFormComponent.propTypes = {
5261

5362
export default function OnboardingFormComponent(props) {
5463
const { error, errorName, submit, cancel, config, billingPlans } = props
55-
const { domainName, minCount, maxCount, computeSize, billing } = config
64+
const { domainName, tier, billing } = config
5665
const hasBilling = !!billing
5766
const hasDomain = !!domainName
5867

5968
const initialValues = {
6069
name: '',
70+
tier: tier || 'default ',
6171
subdomain: '',
62-
planId: '',
63-
overrideDefaults: false,
72+
billingPlan: '',
6473
hasBilling: hasBilling,
6574
hasDomain: hasDomain,
66-
computeSize: computeSize ?? '',
67-
minCount: minCount ?? 1,
68-
maxCount: maxCount ?? 1,
6975
}
7076

7177
const getBillingUi = (plans, hasBilling) => {
@@ -80,7 +86,12 @@ export default function OnboardingFormComponent(props) {
8086
hasBilling && (
8187
<Row>
8288
<Col>
83-
<SaasBoostSelect type="select" name="planId" id="planId" label="Billing Plan">
89+
<SaasBoostSelect
90+
type="select"
91+
name="billingPlan"
92+
id="billingPlan"
93+
label="Billing Plan"
94+
>
8495
<option value="">Select One...</option>
8596
{options}
8697
</SaasBoostSelect>
@@ -94,11 +105,19 @@ export default function OnboardingFormComponent(props) {
94105
return hasDomain ? (
95106
<Row>
96107
<Col sm={8}>
97-
<SaasBoostInput name="subdomain" label="Subdomain" type="text" maxLength={25} />
108+
<SaasBoostInput
109+
name="subdomain"
110+
label="Subdomain"
111+
type="text"
112+
maxLength={25}
113+
/>
98114
</Col>
99115
<Col sm={4}>
100116
<div></div>
101-
<p className="text-muted" style={{ marginLeft: '-20px', marginTop: '42px' }}>
117+
<p
118+
className="text-muted"
119+
style={{ marginLeft: '-20px', marginTop: '42px' }}
120+
>
102121
.{domainName}
103122
</p>
104123
</Col>
@@ -108,41 +127,22 @@ export default function OnboardingFormComponent(props) {
108127

109128
let validationSchema
110129
validationSchema = Yup.object({
111-
name: Yup.string().max(100, 'Must be 100 characters or less.').required('Required'),
130+
name: Yup.string()
131+
.max(100, 'Must be 100 characters or less.')
132+
.required('Required'),
133+
tier: Yup.string().optional(),
112134
subdomain: Yup.string()
113135
.when('hasDomain', {
114136
is: true,
115137
then: Yup.string()
116-
.required('Required because a domain name was specified during application setup')
138+
.required(
139+
'Required because a domain name was specified during application setup'
140+
)
117141
.matches('^[a-zA-Z0-9][a-zA-Z0-9.-]+[a-zA-Z0-9]$'),
118142
otherwise: Yup.string(),
119143
})
120144
.max(25, 'Must be 25 characters or less.'),
121-
computeSize: Yup.string().when('overrideDefaults', {
122-
is: true,
123-
then: Yup.string().required('Instance size is a required field.'),
124-
otherwise: Yup.string(),
125-
}),
126-
minCount: Yup.number().when('overrideDefaults', {
127-
is: true,
128-
then: Yup.number()
129-
.required('Minimum count is a required field.')
130-
.integer('Minimum count must be an integer value')
131-
.min(1, 'Minimum count must be at least ${min}'),
132-
otherwise: Yup.number(),
133-
}),
134-
maxCount: Yup.number().when('overrideDefaults', {
135-
is: true,
136-
then: Yup.number()
137-
.required('Maximum count is a required field.')
138-
.integer('Maximum count must be an integer value')
139-
.max(10, 'Maximum count can be no larger than ${max}')
140-
.test('match', 'Maximum count cannot be smaller than minimum count', function (maxCount) {
141-
return maxCount >= this.parent.minCount
142-
}),
143-
otherwise: Yup.number(),
144-
}),
145-
planId: Yup.string().when('hasBilling', {
145+
billingPlan: Yup.string().when('hasBilling', {
146146
is: true,
147147
then: Yup.string().required('Billing plan is a required field'),
148148
otherwise: Yup.string(),
@@ -167,47 +167,24 @@ export default function OnboardingFormComponent(props) {
167167
<Card>
168168
<CardHeader>Onboarding Request</CardHeader>
169169
<CardBody>
170-
<SaasBoostInput name="name" label="Tenant Name" type="text" maxLength={100} />
171-
{getDomainUi(domainName, hasDomain)}
172-
<SaasBoostCheckbox
173-
name="overrideDefaults"
174-
id="overrideDefaults"
175-
label="Override Application Defaults"
176-
value={formik.values?.overrideDefaults}
177-
></SaasBoostCheckbox>
170+
<SaasBoostInput
171+
name="name"
172+
label="Tenant Name"
173+
type="text"
174+
maxLength={100}
175+
/>
178176
<SaasBoostSelect
179-
disabled={!formik.values.overrideDefaults}
180177
type="select"
181-
name="computeSize"
182-
id="computeSize"
183-
label="Compute Size"
178+
name="tier"
179+
label="Select Tier"
184180
>
185-
<option value="">Select One...</option>
186-
<option value="S">Small</option>
187-
<option value="M">Medium</option>
188-
<option value="L">Large</option>
189-
<option value="XL">X-Large</option>
181+
<option value="default">Default</option>
182+
<option value="S">Silver</option>
183+
<option value="G">Gold</option>
184+
<option value="P">Platinum</option>
185+
<option value="UB">Onobtainium</option>
190186
</SaasBoostSelect>
191-
<Row>
192-
<Col>
193-
<SaasBoostInput
194-
disabled={!formik.values.overrideDefaults}
195-
key="minCount"
196-
label="Minimum Instance Count"
197-
name="minCount"
198-
type="number"
199-
/>
200-
</Col>
201-
<Col>
202-
<SaasBoostInput
203-
disabled={!formik.values.overrideDefaults}
204-
key="maxCount"
205-
label="Maximum Instance Count"
206-
name="maxCount"
207-
type="number"
208-
/>
209-
</Col>
210-
</Row>
187+
{getDomainUi(domainName, hasDomain)}
211188
{getBillingUi(billingPlans, hasBilling)}
212189
<SaasBoostFileUpload
213190
fileMask=".zip"

client/web/src/onboarding/OnboardingTenantLink.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,28 @@
1616
import { PropTypes } from 'prop-types'
1717
import React from 'react'
1818
import { NavLink } from 'reactstrap'
19-
import { isEmpty } from 'lodash'
2019

2120
OnboardingTenantLink.propTypes = {
2221
tenantName: PropTypes.string,
2322
tenantId: PropTypes.string,
2423
clickTenantDetails: PropTypes.func,
2524
}
2625

27-
export function OnboardingTenantLink({ tenantName, tenantId, clickTenantDetails }) {
28-
if (isEmpty(tenantName)) {
29-
tenantName = tenantId.substring(0, 7)
30-
}
26+
//TODO Revisit this when the onboarding service is done. Seems the return shape/vals changed
27+
export function OnboardingTenantLink({
28+
tenantName,
29+
tenantId,
30+
clickTenantDetails,
31+
}) {
3132
return !!tenantId ? (
32-
<NavLink href="#" className="pl-0 pt-0" onClick={() => clickTenantDetails(tenantId)}>
33-
{tenantName}
33+
<NavLink
34+
href="#"
35+
className="pl-0 pt-0"
36+
onClick={() => clickTenantDetails(tenantId)}
37+
>
38+
{tenantName || 'Unknown'}
3439
</NavLink>
3540
) : (
36-
<span>{tenantName}</span>
41+
<span>{tenantName || 'Unknown'}</span>
3742
)
3843
}

0 commit comments

Comments
 (0)