diff --git a/app/scripts/modules/cloudfoundry/src/pipeline/stages/cloneServerGroup/CloudfoundryCloneServerGroupStageConfig.tsx b/app/scripts/modules/cloudfoundry/src/pipeline/stages/cloneServerGroup/CloudfoundryCloneServerGroupStageConfig.tsx index 686ad8ddd30..a51f3e84988 100644 --- a/app/scripts/modules/cloudfoundry/src/pipeline/stages/cloneServerGroup/CloudfoundryCloneServerGroupStageConfig.tsx +++ b/app/scripts/modules/cloudfoundry/src/pipeline/stages/cloneServerGroup/CloudfoundryCloneServerGroupStageConfig.tsx @@ -29,7 +29,6 @@ export class CloudfoundryCloneServerGroupStageConfig extends React.Component< credentials: command.credentials, capacity: command.capacity, account: command.account, - destination: command.destination, delayBeforeDisableSec: command.delayBeforeDisableSec, freeFormDetails: command.freeFormDetails, maxRemainingAsgs: command.maxRemainingAsgs, @@ -40,6 +39,7 @@ export class CloudfoundryCloneServerGroupStageConfig extends React.Component< target: command.target, targetCluster: command.targetCluster, manifest: command.manifest, + source: command.source, }); this.setState({ buttonText: 'Edit clone configuration' }); }; @@ -80,10 +80,10 @@ export class CloudfoundryCloneServerGroupStageConfig extends React.Component< - {stage.credentials} - {stage.region} - {stage.targetCluster} - {cloneTargets.filter(t => t.val === stage.target).map(t => t.label)} + {stage.source ? stage.source.account : ''} + {stage.source ? stage.source.region : ''} + {stage.source ? stage.source.targetCluster : ''} + {stage.source ? cloneTargets.filter(t => t.val === stage.source.target).map(t => t.label) : ''} @@ -99,8 +99,8 @@ export class CloudfoundryCloneServerGroupStageConfig extends React.Component< - {stage.account || ''} - {stage.destination ? stage.destination.region : ''} + {stage.credentials} + {stage.region} diff --git a/app/scripts/modules/cloudfoundry/src/presentation/widgets/accountRegionClusterSelector/FormikAccountRegionClusterSelector.tsx b/app/scripts/modules/cloudfoundry/src/presentation/widgets/accountRegionClusterSelector/FormikAccountRegionClusterSelector.tsx index db4f9e601f3..564dfd80417 100644 --- a/app/scripts/modules/cloudfoundry/src/presentation/widgets/accountRegionClusterSelector/FormikAccountRegionClusterSelector.tsx +++ b/app/scripts/modules/cloudfoundry/src/presentation/widgets/accountRegionClusterSelector/FormikAccountRegionClusterSelector.tsx @@ -22,6 +22,7 @@ export interface IFormikAccountRegionClusterSelectorProps { cloudProvider: string; clusterField?: string; componentName?: string; + credentialsField?: string; formik: FormikProps; } @@ -31,6 +32,7 @@ export interface IFormikAccountRegionClusterSelectorState { clusterField: string; clusters: string[]; componentName: string; + credentialsField: string; } export class FormikAccountRegionClusterSelector extends React.Component< @@ -41,19 +43,26 @@ export class FormikAccountRegionClusterSelector extends React.Component< constructor(props: IFormikAccountRegionClusterSelectorProps) { super(props); + const credentialsField = props.credentialsField || 'credentials'; const clusterField = props.clusterField || 'cluster'; this.state = { availableRegions: [], cloudProvider: props.cloudProvider, - clusterField: clusterField, + clusterField, clusters: [], componentName: props.componentName || '', + credentialsField, }; } public componentDidMount(): void { const { componentName, formik } = this.props; - const credentials = get(formik.values, componentName ? `${componentName}.credentials` : 'credentials', undefined); + const { credentialsField } = this.state; + const credentials = get( + formik.values, + componentName ? `${componentName}.${credentialsField}` : `${credentialsField}`, + undefined, + ); const region = get(formik.values, componentName ? `${componentName}.region` : 'region', undefined); this.setRegionList(credentials); this.setClusterList(credentials, [region]); @@ -94,18 +103,23 @@ export class FormikAccountRegionClusterSelector extends React.Component< public regionChanged = (region: string): void => { const { componentName, formik } = this.props; - const credentials = get(formik.values, componentName ? `${componentName}.credentials` : 'credentials', undefined); + const { credentialsField } = this.state; + const credentials = get( + formik.values, + componentName ? `${componentName}.${credentialsField}` : `${credentialsField}`, + undefined, + ); this.setClusterList(credentials, [region]); }; public render() { const { accounts } = this.props; - const { availableRegions, clusters, clusterField, componentName } = this.state; + const { credentialsField, availableRegions, clusters, clusterField, componentName } = this.state; return (
( diff --git a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupCommandBuilder.service.cf.ts b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupCommandBuilder.service.cf.ts index 70970923cc1..f21577bd12d 100644 --- a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupCommandBuilder.service.cf.ts +++ b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupCommandBuilder.service.cf.ts @@ -66,7 +66,7 @@ export class CloudFoundryServerGroupCommandBuilder { mode = 'clone', ): IPromise { return this.buildNewServerGroupCommand(app, { mode }).then(command => { - command.credentials = serverGroup.account; + command.credentials = ''; command.manifest = { direct: { memory: serverGroup.memory ? serverGroup.memory + 'M' : '1024M', @@ -82,9 +82,14 @@ export class CloudFoundryServerGroupCommandBuilder { healthCheckType: 'port', }, }; - command.region = serverGroup.region; + command.region = ''; command.stack = serverGroup.stack; command.freeFormDetails = serverGroup.detail; + command.source = { + asgName: serverGroup.name, + region: serverGroup.region, + account: serverGroup.account, + }; return command; }); } @@ -150,7 +155,6 @@ export class CloudFoundryServerGroupCommandBuilder { command.credentials = stage.credentials; command.capacity = stage.capacity; command.account = stage.account; - command.destination = stage.destination; command.delayBeforeDisableSec = stage.delayBeforeDisableSec; command.freeFormDetails = stage.freeFormDetails || command.freeFormDetails; command.maxRemainingAsgs = stage.maxRemainingAsgs; @@ -161,6 +165,7 @@ export class CloudFoundryServerGroupCommandBuilder { command.target = stage.target; command.targetCluster = stage.targetCluster; command.manifest = stage.manifest || command.manifest; + command.source = stage.source; command.viewState = { ...command.viewState, diff --git a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupConfigurationModel.cf.ts b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupConfigurationModel.cf.ts index caddff4e91b..8420e9ad53f 100644 --- a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupConfigurationModel.cf.ts +++ b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/serverGroupConfigurationModel.cf.ts @@ -4,7 +4,6 @@ import { ICloudFoundryEnvVar } from 'cloudfoundry/domain'; export interface ICloudFoundryCreateServerGroupCommand extends IServerGroupCommand { // clone server group model account?: string; - destination?: ICloudFoundryDestination; source?: ICloudFoundrySource; rollback?: boolean; target?: string; @@ -35,10 +34,7 @@ export interface ICloudFoundrySource { asgName: string; region: string; account: string; -} - -export interface ICloudFoundryDestination { - region: string; + targetCluster?: string; } export interface ICloudFoundryManifestDirectSource { diff --git a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/CreateServerGroupModal.tsx b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/CreateServerGroupModal.tsx index 313db5a8693..c6d235f32ee 100644 --- a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/CreateServerGroupModal.tsx +++ b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/CreateServerGroupModal.tsx @@ -100,10 +100,7 @@ export class CloudFoundryCreateServerGroupModal extends React.Component< this.props.closeModal && this.props.closeModal(command); } else if (command.viewState.mode === 'clone') { this.state.taskMonitor.submit(() => - ReactInjector.serverGroupWriter.cloneServerGroup( - { destination: { region: command.region, account: command.credentials }, ...command }, - this.props.application, - ), + ReactInjector.serverGroupWriter.cloneServerGroup(command, this.props.application), ); } else { this.state.taskMonitor.submit(() => @@ -114,7 +111,7 @@ export class CloudFoundryCreateServerGroupModal extends React.Component< public render(): React.ReactElement { const { loading, pipeline, isClone, requiresTemplateSelection, stage, taskMonitor } = this.state; - const { application, command, dismissModal, title, isSourceConstant, serverGroup } = this.props; + const { application, command, dismissModal, title, isSourceConstant } = this.props; if (requiresTemplateSelection) { return ( @@ -142,9 +139,7 @@ export class CloudFoundryCreateServerGroupModal extends React.Component< label="Basic Settings" wizard={wizard} order={nextIdx()} - render={({ innerRef }) => ( - - )} + render={({ innerRef }) => } /> {isClone && isSourceConstant && ( @@ -156,7 +151,7 @@ export class CloudFoundryCreateServerGroupModal extends React.Component< )} /> diff --git a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/artifactSettings/ConstantArtifactSettings.cf.tsx b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/artifactSettings/ConstantArtifactSettings.cf.tsx index b5068cae409..1c83e9322d7 100644 --- a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/artifactSettings/ConstantArtifactSettings.cf.tsx +++ b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/artifactSettings/ConstantArtifactSettings.cf.tsx @@ -1,12 +1,15 @@ import * as React from 'react'; -import { ICloudFoundryCreateServerGroupCommand } from 'cloudfoundry/serverGroup/configure/serverGroupConfigurationModel.cf'; -import { ICloudFoundryServerGroup } from 'cloudfoundry/domain'; import { FormikProps } from 'formik'; +import { + ICloudFoundryCreateServerGroupCommand, + ICloudFoundrySource, +} from 'cloudfoundry/serverGroup/configure/serverGroupConfigurationModel.cf'; + export interface ICloudFoundryCloneServerGroupProps { formik: FormikProps; - serverGroup: ICloudFoundryServerGroup; + source: ICloudFoundrySource; } export class CloudFoundryServerGroupConstantArtifactSettings extends React.Component< @@ -14,42 +17,31 @@ export class CloudFoundryServerGroupConstantArtifactSettings extends React.Compo > { constructor(props: ICloudFoundryCloneServerGroupProps) { super(props); - const { serverGroup } = props; - - this.props.formik.values.source = { - account: serverGroup.account, - asgName: serverGroup.name, - region: serverGroup.region, - }; + const { source } = props; + this.props.formik.setFieldValue('source', source); } public render(): JSX.Element { - const { serverGroup } = this.props; + const { source } = this.props; return (
- +
- -
-
-
- -
- +
- +
diff --git a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/basicSettings/BasicSettings.cf.tsx b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/basicSettings/BasicSettings.cf.tsx index 0e73e4bf70d..40f26be6030 100644 --- a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/basicSettings/BasicSettings.cf.tsx +++ b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/basicSettings/BasicSettings.cf.tsx @@ -25,7 +25,6 @@ import 'cloudfoundry/common/cloudFoundry.less'; export interface ICloudFoundryServerGroupBasicSettingsProps { formik: FormikProps; - isClone: boolean; } export interface ICloudFoundryServerGroupLocationSettingsState { @@ -57,13 +56,11 @@ export class CloudFoundryServerGroupBasicSettings private accountChanged = (): void => { this.updateRegionList(); - const regionField = this.props.isClone ? 'destination.region' : 'region'; - this.props.formik.setFieldValue(regionField, ''); + this.props.formik.setFieldValue('region', ''); }; private updateRegionList = (): void => { - const accountField = this.props.isClone ? 'account' : 'credentials'; - const credentials = get(this.props.formik.values, accountField, undefined); + const credentials = get(this.props.formik.values, 'credentials', undefined); if (credentials) { Observable.fromPromise(AccountService.getRegionsForAccount(credentials)) .takeUntil(this.destroy$) @@ -80,17 +77,15 @@ export class CloudFoundryServerGroupBasicSettings }; public render(): JSX.Element { - const { formik, isClone } = this.props; + const { formik } = this.props; const { accounts, regions } = this.state; const { values } = formik; - const accountField = isClone ? 'account' : 'credentials'; - const regionField = isClone ? 'destination.region' : 'region'; return (
( @@ -107,7 +102,7 @@ export class CloudFoundryServerGroupBasicSettings
( diff --git a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/cloneSettings/CloneSettings.cf.tsx b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/cloneSettings/CloneSettings.cf.tsx index 983a4904b9f..829f392693e 100644 --- a/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/cloneSettings/CloneSettings.cf.tsx +++ b/app/scripts/modules/cloudfoundry/src/serverGroup/configure/wizard/sections/cloneSettings/CloneSettings.cf.tsx @@ -67,10 +67,12 @@ export class CloudFoundryServerGroupCloneSettings return (