-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Jason Chu <jjchu@protonmail.com> Co-Authored-By: Joris Melchior <joris.melchior@gmail.com>
- Loading branch information
1 parent
c5e6d3d
commit 04bc98b
Showing
17 changed files
with
712 additions
and
12 deletions.
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
21 changes: 21 additions & 0 deletions
21
...dry/src/pipeline/stages/mapLoadBalancers/CloudfoundryMapLoadBalancersExecutionDetails.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,21 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
ExecutionDetailsSection, | ||
IExecutionDetailsSectionProps, | ||
StageExecutionLogs, | ||
StageFailureMessage, | ||
} from '@spinnaker/core'; | ||
|
||
export function CloudfoundryMapLoadBalancersExecutionDetails(props: IExecutionDetailsSectionProps) { | ||
return ( | ||
<ExecutionDetailsSection name={props.name} current={props.current}> | ||
<StageFailureMessage stage={props.stage} message={props.stage.failureMessage} /> | ||
<StageExecutionLogs stage={props.stage} /> | ||
</ExecutionDetailsSection> | ||
); | ||
} | ||
|
||
export namespace CloudfoundryMapLoadBalancersExecutionDetails { | ||
export const title = 'cloudfoundryMapLoadBalancersConfig'; | ||
} |
109 changes: 109 additions & 0 deletions
109
...dfoundry/src/pipeline/stages/mapLoadBalancers/CloudfoundryMapLoadBalancersStageConfig.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,109 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
Application, | ||
IAccount, | ||
IPipeline, | ||
IStageConfigProps, | ||
NgReact, | ||
StageConfigField, | ||
StageConstants, | ||
} from '@spinnaker/core'; | ||
|
||
import { AccountRegionClusterSelector, Routes } from 'cloudfoundry/presentation'; | ||
import { Formik } from 'formik'; | ||
|
||
interface ICloudfoundryLoadBalancerStageConfigProps extends IStageConfigProps { | ||
accounts: IAccount[]; | ||
pipeline: IPipeline; | ||
} | ||
|
||
interface ICloudFoundryMapLoadBalancersValues { | ||
routes: string[]; | ||
} | ||
|
||
interface ICloudfoundryMapLoadBalancersStageConfigState { | ||
application: Application; | ||
cloudProvider: string; | ||
credentials: string; | ||
initialValues: ICloudFoundryMapLoadBalancersValues; | ||
pipeline: IPipeline; | ||
region: string; | ||
target: string; | ||
} | ||
|
||
export class CloudfoundryMapLoadBalancersStageConfig extends React.Component< | ||
ICloudfoundryLoadBalancerStageConfigProps, | ||
ICloudfoundryMapLoadBalancersStageConfigState | ||
> { | ||
private formikRef = React.createRef<Formik<ICloudFoundryMapLoadBalancersValues>>(); | ||
|
||
constructor(props: ICloudfoundryLoadBalancerStageConfigProps) { | ||
super(props); | ||
props.stage.cloudProvider = 'cloudfoundry'; | ||
this.state = { | ||
application: props.application, | ||
cloudProvider: 'cloudfoundry', | ||
credentials: props.stage.credentials, | ||
initialValues: { | ||
routes: props.stage.loadBalancerNames, | ||
}, | ||
pipeline: props.pipeline, | ||
region: props.stage.region, | ||
target: props.stage.target, | ||
}; | ||
} | ||
|
||
private targetUpdated = (target: string) => { | ||
this.setState({ target }); | ||
this.props.stage.target = target; | ||
this.props.stageFieldUpdated(); | ||
}; | ||
|
||
private componentUpdated = (stage: any): void => { | ||
this.props.stage.credentials = stage.credentials; | ||
this.props.stage.region = stage.region; | ||
this.props.stage.cluster = stage.cluster; | ||
this.props.stage.loadBalancerNames = stage.loadBalancerNames; | ||
this.props.stageFieldUpdated(); | ||
}; | ||
|
||
public render() { | ||
const { accounts, stage } = this.props; | ||
const { application, initialValues, pipeline, target } = this.state; | ||
const { TargetSelect } = NgReact; | ||
return ( | ||
<div className="form-horizontal"> | ||
{!pipeline.strategy && ( | ||
<AccountRegionClusterSelector | ||
accounts={accounts} | ||
application={application} | ||
cloudProvider={'cloudfoundry'} | ||
isSingleRegion={true} | ||
onComponentUpdate={this.componentUpdated} | ||
component={stage} | ||
/> | ||
)} | ||
<StageConfigField label="Target"> | ||
<TargetSelect model={{ target }} options={StageConstants.TARGET_LIST} onChange={this.targetUpdated} /> | ||
</StageConfigField> | ||
<Formik<ICloudFoundryMapLoadBalancersValues> | ||
ref={this.formikRef} | ||
initialValues={initialValues} | ||
onSubmit={null} | ||
render={() => { | ||
return ( | ||
<Routes | ||
fieldName={'routes'} | ||
onChange={(routes: string[]) => { | ||
stage.loadBalancerNames = routes; | ||
this.componentUpdated(stage); | ||
}} | ||
/> | ||
); | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../cloudfoundry/src/pipeline/stages/mapLoadBalancers/cloudfoundryMapLoadBalancersStage.html
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 @@ | ||
<cf-map-load-balancers-stage accounts="accounts" application="application" pipeline="pipeline" stage="stage" stage-field-updated="stageFieldUpdated" /> |
49 changes: 49 additions & 0 deletions
49
...dfoundry/src/pipeline/stages/mapLoadBalancers/cloudfoundryMapLoadBalancersStage.module.ts
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,49 @@ | ||
import { IController, IScope, module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
|
||
import { CloudfoundryMapLoadBalancersStageConfig } from './CloudfoundryMapLoadBalancersStageConfig'; | ||
import { AccountService, ExecutionDetailsTasks, IStage, Registry } from '@spinnaker/core'; | ||
import { CloudfoundryMapLoadBalancersExecutionDetails } from './CloudfoundryMapLoadBalancersExecutionDetails'; | ||
|
||
class CloudFoundryMapLoadBalancersStageCtrl implements IController { | ||
constructor(public $scope: IScope) { | ||
'ngInject'; | ||
$scope.accounts = []; | ||
AccountService.listAccounts('cloudfoundry').then(accounts => { | ||
$scope.accounts = accounts; | ||
}); | ||
} | ||
} | ||
|
||
export const CLOUD_FOUNDRY_MAP_LOAD_BALANCERS_STAGE = 'spinnaker.cloudfoundry.pipeline.stage.mapLoadBalancersStage'; | ||
module(CLOUD_FOUNDRY_MAP_LOAD_BALANCERS_STAGE, []) | ||
.config(function() { | ||
Registry.pipeline.registerStage({ | ||
accountExtractor: (stage: IStage) => stage.context.credentials, | ||
configAccountExtractor: (stage: IStage) => [stage.credentials], | ||
cloudProvider: 'cloudfoundry', | ||
controller: 'cfMapLoadBalancersStageCtrl', | ||
description: 'Map load balancers', | ||
executionDetailsSections: [CloudfoundryMapLoadBalancersExecutionDetails, ExecutionDetailsTasks], | ||
key: 'mapLoadBalancers', | ||
label: 'Map Load Balancers', | ||
templateUrl: require('./cloudfoundryMapLoadBalancersStage.html'), | ||
validators: [ | ||
{ type: 'requiredField', fieldName: 'cluster' }, | ||
{ type: 'requiredField', fieldName: 'credentials', fieldLabel: 'account' }, | ||
{ type: 'requiredField', fieldName: 'region' }, | ||
{ type: 'requiredField', fieldName: 'target' }, | ||
], | ||
}); | ||
}) | ||
.component( | ||
'cfMapLoadBalancersStage', | ||
react2angular(CloudfoundryMapLoadBalancersStageConfig, [ | ||
'accounts', | ||
'application', | ||
'pipeline', | ||
'stage', | ||
'stageFieldUpdated', | ||
]), | ||
) | ||
.controller('cfMapLoadBalancersStageCtrl', CloudFoundryMapLoadBalancersStageCtrl); |
21 changes: 21 additions & 0 deletions
21
...src/pipeline/stages/unmapLoadBalancers/CloudfoundryUnmapLoadBalancersExecutionDetails.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,21 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
ExecutionDetailsSection, | ||
IExecutionDetailsSectionProps, | ||
StageExecutionLogs, | ||
StageFailureMessage, | ||
} from '@spinnaker/core'; | ||
|
||
export function CloudfoundryUnmapLoadBalancersExecutionDetails(props: IExecutionDetailsSectionProps) { | ||
return ( | ||
<ExecutionDetailsSection name={props.name} current={props.current}> | ||
<StageFailureMessage stage={props.stage} message={props.stage.failureMessage} /> | ||
<StageExecutionLogs stage={props.stage} /> | ||
</ExecutionDetailsSection> | ||
); | ||
} | ||
|
||
export namespace CloudfoundryUnmapLoadBalancersExecutionDetails { | ||
export const title = 'cloudfoundryUnmapLoadBalancersConfig'; | ||
} |
Oops, something went wrong.