-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(deploy/blockDevices): Adds a Volume section in the Deploy wizard #8911
Open
jorgebee65
wants to merge
24
commits into
spinnaker:master
Choose a base branch
from
armory-io:blockDeviceTags
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b9107e4
feat(deploy/blockDevices): Add a Volume section in the Deploy Wizzard…
jorgebee65 d566588
Merge branch 'master' of https://github.com/spinnaker/deck into block…
jorgebee65 9c209f6
feat(blockDevice/tags): add other volumeTypes
jorgebee65 bfce1d8
Merge branch 'master' into blockDeviceTags
jorgebee65 74f92ce
Merge branch 'master' into blockDeviceTags
jorgebee65 aedb62c
feat(blockDevice/tags): rename attribute to blockDeviceTags
jorgebee65 e111619
feat(blockDevice/tags): fix imports in AmazonCloneServerGroupModal.tsx
jorgebee65 f93f476
feat(blockDevice/tags): fix imports in AmazonCloneServerGroupModal.tsx
jorgebee65 8e47e4b
Merge branch 'master' into blockDeviceTags
jorgebee65 8527537
Merge branch 'master' into blockDeviceTags
jorgebee65 e8239c9
Merge branch 'master' into blockDeviceTags
rvazquezglez fa4b76e
Merge branch 'master' into blockDeviceTags
jorgebee65 63c2fe9
Merge branch 'master' into blockDeviceTags
zachsmith1 c68a2ee
Merge branch 'master' into blockDeviceTags
jorgebee65 232664f
Merge branch 'master' into blockDeviceTags
jorgebee65 7cecd63
Merge branch 'master' into blockDeviceTags
jorgebee65 709ccb5
Update app/scripts/modules/amazon/src/serverGroup/configure/serverGro…
jorgebee65 e6944aa
Merge branch 'master' into blockDeviceTags
zachsmith1 5d3b65b
Merge branch 'master' into blockDeviceTags
zachsmith1 2f05a95
refactor(amazon/volumes): Refactoring the code implementing FormikFor…
jorgebee65 b1d5ca3
refactor(amazon/volumes): Make some fields required and other optiona…
jorgebee65 41d5cc3
Merge branch 'master' into blockDeviceTags
jorgebee65 af52e1f
Merge branch 'master' into blockDeviceTags
jorgebee65 89ee718
Merge branch 'master' into blockDeviceTags
jorgebee65 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/amazon/src/serverGroup/configure/wizard/pages/volumes/ConfigureConfigModal.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.configure-config-modal .StandardFieldLayout .sm-label-right { | ||
min-width: 160px; | ||
} | ||
|
162 changes: 162 additions & 0 deletions
162
packages/amazon/src/serverGroup/configure/wizard/pages/volumes/ConfigureVolumeModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { Form } from 'formik'; | ||
import React from 'react'; | ||
import { Modal } from 'react-bootstrap'; | ||
|
||
import { | ||
FormikFormField, | ||
CheckboxInput, | ||
HelpField, | ||
ModalClose, | ||
noop, | ||
NumberInput, | ||
ReactModal, | ||
SelectInput, | ||
SpinFormik, | ||
SubmitButton, | ||
TextInput, | ||
} from '@spinnaker/core'; | ||
import { IServerGroupCommandBlockDevice } from '../../../serverGroupConfiguration.service'; | ||
|
||
import './ConfigureConfigModal.css'; | ||
|
||
export interface IConfigureVolumeConfigModalProps { | ||
config: IServerGroupCommandBlockDevice; | ||
closeModal?(result?: any): void; // provided by ReactModal | ||
dismissModal?(rejection?: any): void; // provided by ReactModal | ||
} | ||
|
||
export class ConfigureVolumeConfigModal extends React.Component<IConfigureVolumeConfigModalProps> { | ||
private initialValues: IServerGroupCommandBlockDevice; | ||
private volumeTypes = ['gp2', 'gp3', 'st1', 'io1', 'io2', 'sc1']; | ||
|
||
public static defaultProps: Partial<IConfigureVolumeConfigModalProps> = { | ||
closeModal: noop, | ||
dismissModal: noop, | ||
}; | ||
|
||
public static show(props: IConfigureVolumeConfigModalProps): Promise<void> { | ||
return ReactModal.show(ConfigureVolumeConfigModal, props); | ||
} | ||
|
||
constructor(props: IConfigureVolumeConfigModalProps) { | ||
super(props); | ||
|
||
const config = props.config || ({} as IServerGroupCommandBlockDevice); | ||
|
||
this.initialValues = { | ||
deviceName: config.deviceName || '/dev/sdh', | ||
deleteOnTermination: config.deleteOnTermination, | ||
size: config.size || 16, | ||
volumeType: config.volumeType || 'gp2', | ||
virtualName: config.virtualName || '', | ||
iops: config.iops, | ||
snapshotId: config.snapshotId || '', | ||
encrypted: config.encrypted, | ||
}; | ||
} | ||
|
||
private close = (reason?: null): void => { | ||
this.props.dismissModal(reason); | ||
}; | ||
|
||
private submit = (data: IServerGroupCommandBlockDevice): void => { | ||
this.props.closeModal(data); | ||
}; | ||
|
||
public render() { | ||
const submitLabel = 'Save Device'; | ||
|
||
return ( | ||
<div className="configure-config-modal"> | ||
<SpinFormik<IServerGroupCommandBlockDevice> | ||
initialValues={this.initialValues} | ||
onSubmit={this.submit} | ||
render={({ isValid }) => ( | ||
<Form className="form-horizontal"> | ||
<ModalClose dismiss={this.close} /> | ||
<Modal.Header> | ||
<Modal.Title> | ||
Configure Volume | ||
</Modal.Title> | ||
</Modal.Header> | ||
|
||
<Modal.Body> | ||
<FormikFormField | ||
name="deleteOnTermination" | ||
label="Delete on Termination" | ||
help={<HelpField id="aws.securityGroup.volume.delete.on.termination" />} | ||
input={(props) => <CheckboxInput {...props} />} /> | ||
|
||
<FormikFormField | ||
name="encrypted" | ||
label="Encrypted" | ||
help={<HelpField id="aws.securityGroup.volume.encrypted" />} | ||
input={(props) => <CheckboxInput {...props} />} /> | ||
|
||
<FormikFormField | ||
name="deviceName" | ||
label="Device Name" | ||
required={true} | ||
input={(props) => <TextInput {...props} />} | ||
help={<HelpField id="aws.securityGroup.volume.devicename" />} | ||
/> | ||
|
||
<FormikFormField | ||
name="volumeType" | ||
label="Volune Type" | ||
required={true} | ||
help={<HelpField id="aws.securityGroup.volume.type" />} | ||
input={(props) => ( | ||
<SelectInput | ||
options={this.volumeTypes} | ||
{...props} | ||
/> | ||
)} | ||
/> | ||
|
||
<FormikFormField | ||
name="virtualName" | ||
label="Virtual Name" | ||
required={false} | ||
input={(props) => <TextInput {...props} />} | ||
help={<HelpField id="aws.securityGroup.volume.virtual.name" />} | ||
/> | ||
|
||
<FormikFormField | ||
name="snapshotId" | ||
label="Snapshot Id" | ||
required={false} | ||
input={(props) => <TextInput {...props} />} | ||
help={<HelpField id="aws.securityGroup.volume.snapshot" />} | ||
/> | ||
|
||
<FormikFormField | ||
name="size" | ||
label="Size" | ||
required={true} | ||
input={(props) => <NumberInput {...props} />} | ||
help={<HelpField id="aws.securityGroup.volume.size" />} | ||
/> | ||
|
||
<FormikFormField | ||
name="iops" | ||
label="Iops" | ||
required={false} | ||
input={(props) => <NumberInput {...props} />} | ||
help={<HelpField id="aws.securityGroup.volume.iops" />} | ||
/> | ||
</Modal.Body> | ||
|
||
<Modal.Footer> | ||
<button className="btn btn-default" onClick={this.close} type="button"> | ||
Cancel | ||
</button> | ||
<SubmitButton isDisabled={!isValid} submitting={false} isFormSubmit={true} label={submitLabel} /> | ||
</Modal.Footer> | ||
</Form> | ||
)} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
packages/amazon/src/serverGroup/configure/wizard/pages/volumes/ServerGroupVolumes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { FormikProps } from 'formik'; | ||
import { VolumeEditor } from './VolumeEditor'; | ||
|
||
import { Application, IServerGroup, IWizardPageComponent, MapEditor, HelpField } from '@spinnaker/core'; | ||
|
||
import { IAmazonServerGroupCommand } from '../../../serverGroupConfiguration.service'; | ||
import { isNil } from 'lodash'; | ||
|
||
export interface IServerGroupVolumesProps { | ||
app: Application; | ||
formik: FormikProps<IAmazonServerGroupCommand>; | ||
} | ||
|
||
export interface IServerGroupVolumesState { | ||
namePreview: string; | ||
createsNewCluster: boolean; | ||
latestServerGroup: IServerGroup; | ||
} | ||
|
||
export class ServerGroupVolumes | ||
extends React.Component<IServerGroupVolumesProps, IServerGroupVolumesState> | ||
implements IWizardPageComponent<IAmazonServerGroupCommand> { | ||
private duplicateKeys = false; | ||
|
||
public validate() { | ||
const errors = {} as any; | ||
if (this.duplicateKeys) { | ||
errors.tags = 'Tags have duplicate keys.'; | ||
} | ||
return errors; | ||
} | ||
|
||
|
||
|
||
private tagsChanged = (tags: { [key: string]: string }, duplicateKeys: boolean) => { | ||
this.duplicateKeys = duplicateKeys; | ||
this.props.formik.setFieldValue('blockDeviceTags', tags); | ||
}; | ||
|
||
constructor(props: IServerGroupVolumesProps) { | ||
super(props); | ||
} | ||
|
||
public render() { | ||
const { values } = this.props.formik; | ||
const { app } = this.props; | ||
const blockTags = isNil(values.blockDeviceTags) ? [] : values.blockDeviceTags; | ||
|
||
return ( | ||
<div className="container-fluid form-horizontal"> | ||
<div className="form-group"> | ||
<div className="sm-label-left"> | ||
<b>Volumes (optional)</b> | ||
</div> | ||
<VolumeEditor | ||
app={app} | ||
formik={this.props.formik} | ||
/> | ||
</div> | ||
<div className="form-group"> | ||
<div className="sm-label-left"> | ||
<b>Tags (optional)</b> | ||
<HelpField id="aws.serverGroup.blockDevice.tags" /> | ||
</div> | ||
<MapEditor model={blockTags as any} allowEmpty={true} onChange={this.tagsChanged} /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use a
FormikFormField
and aMapEditorInput
which would also make thevalidate
and `tagsChanged functions unnecessary