Skip to content
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(cf): create AccountRegionClusterSelector React component #6314

Merged
merged 4 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/scripts/modules/cloudfoundry/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export * from './cf.settings';

export * from './domain/index';
export * from './loadBalancer/index';
export * from './serverGroup/index';
export * from './presentation/index';
export * from './reactShims/index';
export * from './serverGroup/index';
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
StageConfigField,
} from '@spinnaker/core';

import { AccountRegionClusterSelector } from 'cloudfoundry/presentation';

export interface ICloudfoundryDestroyAsgStageProps extends IStageConfigProps {
pipeline: IPipeline;
}
Expand Down Expand Up @@ -70,22 +72,27 @@ export class CloudfoundryDestroyAsgStageConfig extends React.Component<
this.props.stageFieldUpdated();
};

private componentUpdate = (stage: any): void => {
this.props.stage.credentials = stage.credentials;
this.props.stage.regions = stage.regions;
this.props.stage.cluster = stage.cluster;
this.props.stageFieldUpdated();
};

public render() {
const { stage, stageFieldUpdated } = this.props;
const { stage } = this.props;
const { accounts, application, pipeline, target } = this.state;
const { AccountRegionClusterSelector, TargetSelect } = NgReact;
const { TargetSelect } = NgReact;
return (
<div className="form-horizontal">
{!pipeline.strategy && (
<div>
<AccountRegionClusterSelector
application={application}
clusterField="cluster"
component={stage}
onAccountUpdate={stageFieldUpdated}
accounts={accounts}
/>
</div>
<AccountRegionClusterSelector
accounts={accounts}
application={application}
cloudProvider={'cloudfoundry'}
onComponentUpdate={this.componentUpdate}
component={stage}
/>
)}

<StageConfigField label="Target">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
StageConfigField,
} from '@spinnaker/core';

import { AccountRegionClusterSelector } from 'cloudfoundry/presentation';

export interface ICloudfoundryDisableAsgStageProps extends IStageConfigProps {
pipeline: IPipeline;
}
Expand Down Expand Up @@ -65,31 +67,36 @@ export class CloudfoundryDisableAsgStageConfig extends React.Component<
};

private targetUpdated = (target: string) => {
this.setState({ target: target });
this.setState({ target });
this.props.stage.target = target;
this.props.stageFieldUpdated();
};

private componentUpdate = (stage: any): void => {
this.props.stage.credentials = stage.credentials;
this.props.stage.regions = stage.regions;
this.props.stage.cluster = stage.cluster;
this.props.stageFieldUpdated();
};

public render() {
const { stage, stageFieldUpdated } = this.props;
const { stage } = this.props;
const { accounts, application, pipeline, target } = this.state;
const { AccountRegionClusterSelector, TargetSelect } = NgReact;
const { TargetSelect } = NgReact;
return (
<div className="form-horizontal">
{!pipeline.strategy && (
<div>
<AccountRegionClusterSelector
application={application}
clusterField="cluster"
component={stage}
onAccountUpdate={stageFieldUpdated}
accounts={accounts}
/>
</div>
<AccountRegionClusterSelector
accounts={accounts}
application={application}
cloudProvider={'cloudfoundry'}
onComponentUpdate={this.componentUpdate}
component={stage}
/>
)}

<StageConfigField label="Target">
<TargetSelect model={{ target: target }} options={StageConstants.TARGET_LIST} onChange={this.targetUpdated} />
<TargetSelect model={{ target }} options={StageConstants.TARGET_LIST} onChange={this.targetUpdated} />
</StageConfigField>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
StageConfigField,
} from '@spinnaker/core';

import { AccountRegionClusterSelector } from 'cloudfoundry/presentation';

export interface ICloudfoundryEnableAsgStageProps extends IStageConfigProps {
pipeline: IPipeline;
}
Expand Down Expand Up @@ -70,22 +72,27 @@ export class CloudfoundryEnableAsgStageConfig extends React.Component<
this.props.stageFieldUpdated();
};

private componentUpdate = (stage: any): void => {
this.props.stage.credentials = stage.credentials;
this.props.stage.regions = stage.regions;
this.props.stage.cluster = stage.cluster;
this.props.stageFieldUpdated();
};

public render() {
const { stage, stageFieldUpdated } = this.props;
const { stage } = this.props;
const { accounts, application, pipeline, target } = this.state;
const { AccountRegionClusterSelector, TargetSelect } = NgReact;
const { TargetSelect } = NgReact;
return (
<div className="form-horizontal">
{!pipeline.strategy && (
<div>
<AccountRegionClusterSelector
application={application}
clusterField="cluster"
component={stage}
onAccountUpdate={stageFieldUpdated}
accounts={accounts}
/>
</div>
<AccountRegionClusterSelector
accounts={accounts}
application={application}
cloudProvider={'cloudfoundry'}
onComponentUpdate={this.componentUpdate}
component={stage}
/>
)}

<StageConfigField label="Target">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
StageConfigField,
} from '@spinnaker/core';

import { AccountRegionClusterSelector } from 'cloudfoundry/presentation';

export interface ICloudfoundryResizeAsgStageProps extends IStageConfigProps {
pipeline: IPipeline;
}
Expand Down Expand Up @@ -126,26 +128,31 @@ export class CloudfoundryResizeAsgStageConfig extends React.Component<
this.props.stageFieldUpdated();
};

private componentUpdate = (stage: any): void => {
this.props.stage.credentials = stage.credentials;
this.props.stage.regions = stage.regions;
this.props.stage.cluster = stage.cluster;
this.props.stageFieldUpdated();
};

public render() {
const { accounts, application, pipeline, resizeLabel, resizeMessage } = this.state;
const { stage } = this.props;
const { capacity, target } = this.props.stage;
const diskQuota = this.props.stage.diskQuota;
const instanceCount = capacity.desired;
const memory = this.props.stage.memory;
const { AccountRegionClusterSelector, TargetSelect } = NgReact;
const { TargetSelect } = NgReact;
return (
<div className="cloudfoundry-resize-asg-stage form-horizontal">
{!pipeline.strategy && (
<div>
<AccountRegionClusterSelector
application={application}
clusterField="cluster"
component={stage}
onAccountUpdate={this.props.stageFieldUpdated}
accounts={accounts}
/>
</div>
<AccountRegionClusterSelector
accounts={accounts}
application={application}
cloudProvider={'cloudfoundry'}
onComponentUpdate={this.componentUpdate}
component={stage}
/>
)}
<StageConfigField label="Target">
<TargetSelect model={{ target: target }} options={StageConstants.TARGET_LIST} onChange={this.targetUpdated} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
IPipeline,
IRegion,
IStageConfigProps,
NgReact,
StageConfigField,
} from '@spinnaker/core';

import { AccountRegionClusterSelector } from 'cloudfoundry/presentation';

export interface ICloudfoundryRollbackClusterStageProps extends IStageConfigProps {
pipeline: IPipeline;
}
Expand Down Expand Up @@ -62,23 +63,27 @@ export class CloudfoundryRollbackClusterStageConfig extends React.Component<
this.props.stageFieldUpdated();
};

private componentUpdate = (stage: any): void => {
this.props.stage.credentials = stage.credentials;
this.props.stage.regions = stage.regions;
this.props.stage.cluster = stage.cluster;
this.props.stageFieldUpdated();
};

public render() {
const { stage, stageFieldUpdated } = this.props;
const { stage } = this.props;
const { waitTimeBetweenRegions } = stage;
const { accounts, application, pipeline } = this.state;
const { AccountRegionClusterSelector } = NgReact;
return (
<div className="form-horizontal">
{!pipeline.strategy && (
<div>
<AccountRegionClusterSelector
application={application}
clusterField="cluster"
component={stage}
onAccountUpdate={stageFieldUpdated}
accounts={accounts}
/>
</div>
<AccountRegionClusterSelector
accounts={accounts}
application={application}
cloudProvider={'cloudfoundry'}
onComponentUpdate={this.componentUpdate}
component={stage}
/>
)}

{stage.regions.length > 1 && (
Expand Down
1 change: 1 addition & 0 deletions app/scripts/modules/cloudfoundry/src/presentation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './widgets';
Loading