-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core/delivery): Convert waitExecutionDetails to react (#4297)
- Loading branch information
Justin Reynolds
authored
Oct 21, 2017
1 parent
26aad5e
commit 9dcc554
Showing
15 changed files
with
186 additions
and
109 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
43 changes: 43 additions & 0 deletions
43
app/scripts/modules/core/src/delivery/details/StageExecutionDetails.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,43 @@ | ||
import * as React from 'react'; | ||
import { isEqual } from 'lodash'; | ||
|
||
import { IExecutionDetailsComponentProps, IExecutionDetailsComponentState } from 'core/domain'; | ||
import { ReactInjector } from 'core/reactShims'; | ||
|
||
export function stageExecutionDetails(WrappedStageExecutionDetails: React.ComponentClass<IExecutionDetailsComponentProps>): React.ComponentClass<IExecutionDetailsComponentProps> { | ||
return class extends React.Component<IExecutionDetailsComponentProps, IExecutionDetailsComponentState> { | ||
constructor(props: IExecutionDetailsComponentProps) { | ||
super(props); | ||
this.state = { | ||
detailsSection: null, | ||
} | ||
} | ||
|
||
public updateDetailsSection(): void { | ||
const detailsSection = ReactInjector.$stateParams.details; | ||
if (this.state.detailsSection !== detailsSection) { | ||
this.setState({detailsSection}); | ||
} | ||
} | ||
|
||
public syncDetails(props: IExecutionDetailsComponentProps): void { | ||
ReactInjector.executionDetailsSectionService.synchronizeSection(props.configSections, () => this.updateDetailsSection()); | ||
} | ||
|
||
public componentDidMount(): void { | ||
this.syncDetails(this.props); | ||
} | ||
|
||
public componentWillReceiveProps(nextProps: IExecutionDetailsComponentProps): void { | ||
if (!isEqual(nextProps.configSections, this.props.configSections)) { | ||
this.syncDetails(nextProps); | ||
} | ||
} | ||
|
||
public render() { | ||
return ( | ||
<WrappedStageExecutionDetails detailsSection={this.state.detailsSection} {...this.props} /> | ||
); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/scripts/modules/core/src/delivery/details/StageExecutionLogs.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 { get } from 'lodash'; | ||
|
||
import { IStage } from 'core/domain'; | ||
|
||
export const StageExecutionLogs = (props: { stage: IStage }): JSX.Element => { | ||
const logs = get<string>(props.stage, 'context.execution.logs'); | ||
if (!logs) { return null; } | ||
|
||
return ( | ||
<div className="row"> | ||
<div className="col-md-12"> | ||
<div className="well alert alert-info"> | ||
<a target="_blank" href={logs}> | ||
View Execution Logs | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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 @@ | ||
export * from './ExecutionDetailsSectionNav'; | ||
export * from './StageExecutionDetails'; | ||
export * from './StageExecutionLogs'; | ||
export * from './StageFailureMessage'; |
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: 0 additions & 24 deletions
24
app/scripts/modules/core/src/pipeline/config/stages/group/waitExecutionDetails.html
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
app/scripts/modules/core/src/pipeline/config/stages/wait/WaitExecutionDetails.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,35 @@ | ||
import * as React from 'react'; | ||
|
||
import { IExecutionDetailsComponentProps } from 'core/domain'; | ||
import { ExecutionDetailsSectionNav, StageExecutionLogs, StageFailureMessage } from 'core/delivery/details'; | ||
import { ExecutionStepDetails } from 'core/pipeline/config/stages/core/ExecutionStepDetails'; | ||
import { SkipWait } from './SkipWait'; | ||
import { stageExecutionDetails } from 'core/delivery/details'; | ||
|
||
class ExecutionDetails extends React.Component<IExecutionDetailsComponentProps> { | ||
public render() { | ||
const { application, configSections, detailsSection, execution, stage } = this.props; | ||
return ( | ||
<div> | ||
<ExecutionDetailsSectionNav sections={configSections} /> | ||
{detailsSection === 'waitConfig' && ( | ||
<div className="step-section-details"> | ||
<SkipWait application={application} execution={execution} stage={stage} /> | ||
<StageFailureMessage stage={stage} message={stage.failureMessage} /> | ||
<StageExecutionLogs stage={stage} /> | ||
</div> | ||
)} | ||
|
||
{detailsSection === 'taskStatus' && ( | ||
<div className="step-section-details"> | ||
<div className="row"> | ||
<ExecutionStepDetails item={stage} /> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export const WaitExecutionDetails = stageExecutionDetails(ExecutionDetails); |
24 changes: 0 additions & 24 deletions
24
app/scripts/modules/core/src/pipeline/config/stages/wait/waitExecutionDetails.html
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
app/scripts/modules/core/src/pipeline/config/stages/wait/waitStage.js
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
app/scripts/modules/core/src/pipeline/config/stages/wait/waitStage.module.js
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
app/scripts/modules/core/src/pipeline/config/stages/wait/waitStage.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,8 @@ | ||
import { module } from 'angular'; | ||
|
||
import { WAIT_STAGE } from './waitStage'; | ||
|
||
export const WAIT_STAGE_MODULE = 'spinnaker.core.pipeline.stage.wait'; | ||
module(WAIT_STAGE_MODULE, [ | ||
WAIT_STAGE, | ||
]); |
32 changes: 32 additions & 0 deletions
32
app/scripts/modules/core/src/pipeline/config/stages/wait/waitStage.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,32 @@ | ||
import { module } from 'angular'; | ||
|
||
import { IStage } from 'core/domain'; | ||
import { PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from 'core/pipeline/config/pipelineConfigProvider'; | ||
|
||
import { SKIP_WAIT_COMPONENT } from './skipWait.component'; | ||
import { WaitExecutionDetails } from './WaitExecutionDetails'; | ||
import { WaitExecutionLabel } from './WaitExecutionLabel'; | ||
|
||
export const WAIT_STAGE = 'spinnaker.core.pipeline.stage.waitStage'; | ||
|
||
module(WAIT_STAGE, [ | ||
PIPELINE_CONFIG_PROVIDER, | ||
SKIP_WAIT_COMPONENT, | ||
]) | ||
.config((pipelineConfigProvider: PipelineConfigProvider) => { | ||
pipelineConfigProvider.registerStage({ | ||
label: 'Wait', | ||
description: 'Waits a specified period of time', | ||
key: 'wait', | ||
templateUrl: require('./waitStage.html'), | ||
executionDetailsComponent: WaitExecutionDetails, | ||
executionConfigSections: ['waitConfig', 'taskStatus'], | ||
executionLabelComponent: WaitExecutionLabel, | ||
useCustomTooltip: true, | ||
strategy: true, | ||
controller: 'WaitStageCtrl', | ||
validators: [ | ||
{ type: 'requiredField', fieldName: 'waitTime' }, | ||
], | ||
}); | ||
}).controller('WaitStageCtrl', (stage: IStage) => stage.waitTime = stage.waitTime || 30); |
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