Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(kubernetes): convert deploy manifest stage to react (#7002)
- Loading branch information
1 parent
96ac95a
commit 53cb422
Showing
29 changed files
with
438 additions
and
419 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
24 changes: 24 additions & 0 deletions
24
app/scripts/modules/core/src/artifact/react/StageArtifactSelectorDelegate.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,24 @@ | ||
import * as React from 'react'; | ||
|
||
import { StageConfigField } from 'core/pipeline'; | ||
import { SETTINGS } from 'core/config/settings'; | ||
|
||
import { StageArtifactSelector, IStageArtifactSelectorProps } from './StageArtifactSelector'; | ||
import { PreRewriteStageArtifactSelector, IPreRewriteArtifactSelectorProps } from './PreRewriteStageArtifactSelector'; | ||
|
||
interface IStageArtifactSelectorDelegateProps { | ||
helpKey: string; | ||
label: string; | ||
} | ||
|
||
export const StageArtifactSelectorDelegate = ( | ||
props: IStageArtifactSelectorProps & IPreRewriteArtifactSelectorProps & IStageArtifactSelectorDelegateProps, | ||
) => { | ||
return SETTINGS.feature['artifactsRewrite'] ? ( | ||
<StageConfigField label={props.label} helpKey={props.helpKey}> | ||
<StageArtifactSelector {...props} /> | ||
</StageConfigField> | ||
) : ( | ||
<PreRewriteStageArtifactSelector {...props} /> | ||
); | ||
}; |
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
2 changes: 1 addition & 1 deletion
2
app/scripts/modules/kubernetes/src/v2/manifest/manifestEvents.component.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
40 changes: 0 additions & 40 deletions
40
app/scripts/modules/kubernetes/src/v2/manifest/wizard/basicSettings.component.ts
This file was deleted.
Oops, something went wrong.
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
80 changes: 80 additions & 0 deletions
80
...s/modules/kubernetes/src/v2/pipelines/stages/deployManifest/DeployManifestStageConfig.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,80 @@ | ||
import * as React from 'react'; | ||
import { cloneDeep } from 'lodash'; | ||
import { Observable, Subject } from 'rxjs'; | ||
|
||
import { AccountService, FormikStageConfig, IAccountDetails, IStage, IStageConfigProps } from '@spinnaker/core'; | ||
|
||
import { DeployManifestStageForm } from './DeployManifestStageForm'; | ||
import { defaultTrafficManagementConfig } from './ManifestDeploymentOptions'; | ||
|
||
interface IDeployManifestStageConfigState { | ||
accounts: IAccountDetails[]; | ||
} | ||
|
||
export class DeployManifestStageConfig extends React.Component<IStageConfigProps, IDeployManifestStageConfigState> { | ||
private stage: IStage; | ||
private destroy$ = new Subject(); | ||
|
||
public constructor(props: IStageConfigProps) { | ||
super(props); | ||
this.state = { | ||
accounts: [], | ||
}; | ||
const { stage: initialStageConfig } = props; | ||
const stage = cloneDeep(initialStageConfig); | ||
if (!stage.source) { | ||
stage.source = 'text'; | ||
} | ||
if (!stage.skipExpressionEvaluation) { | ||
stage.skipExpressionEvaluation = false; | ||
} | ||
if (!stage.trafficManagement) { | ||
stage.trafficManagement = defaultTrafficManagementConfig; | ||
} | ||
if (!stage.cloudProvider) { | ||
stage.cloudProvider = 'kubernetes'; | ||
} | ||
if (!stage.moniker) { | ||
stage.moniker = {}; | ||
} | ||
if (!stage.moniker.app) { | ||
stage.moniker.app = props.application.name; | ||
} | ||
// Intentionally initializing the stage config only once in the constructor | ||
// The stage config is then completely owned within FormikStageConfig's Formik state | ||
this.stage = stage; | ||
} | ||
|
||
public componentDidMount() { | ||
this.fetchAccounts(); | ||
} | ||
|
||
private fetchAccounts = (): void => { | ||
Observable.fromPromise(AccountService.getAllAccountDetailsForProvider('kubernetes', 'v2')) | ||
.takeUntil(this.destroy$) | ||
.subscribe((accounts: IAccountDetails[]) => { | ||
this.setState({ accounts }); | ||
}); | ||
}; | ||
|
||
public componentWillUnmount() { | ||
this.destroy$.next(); | ||
} | ||
|
||
public render() { | ||
return ( | ||
<FormikStageConfig | ||
{...this.props} | ||
stage={this.stage} | ||
onChange={this.props.updateStage} | ||
render={props => ( | ||
<DeployManifestStageForm | ||
{...props} | ||
accounts={this.state.accounts} | ||
updatePipeline={this.props.updatePipeline} | ||
/> | ||
)} | ||
/> | ||
); | ||
} | ||
} |
Oops, something went wrong.