-
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.
refactor(core): reactify overrideFailure component (#7107)
- Loading branch information
Jammy Louie
committed
Jun 12, 2019
1 parent
4f07aeb
commit 4e2f749
Showing
8 changed files
with
136 additions
and
116 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
app/scripts/modules/core/src/pipeline/config/stages/overrideFailure/OverrideFailure.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,93 @@ | ||
import * as React from 'react'; | ||
|
||
import { IStage } from 'core/domain'; | ||
import { HelpField } from 'core/help'; | ||
import { RadioButtonInput } from 'core/presentation'; | ||
import { StageConfigField } from 'core/pipeline'; | ||
|
||
import './overrideFailure.less'; | ||
|
||
export interface IOverrideFailureConfigProps { | ||
failPipeline: boolean; | ||
continuePipeline: boolean; | ||
completeOtherBranchesThenFail: boolean; | ||
updateStageField: (changes: Partial<IStage>) => void; | ||
} | ||
|
||
export const OverrideFailure = (props: IOverrideFailureConfigProps) => { | ||
const overrideFailureOptions = [ | ||
{ | ||
label: 'halt the entire pipeline', | ||
value: 'fail', | ||
help: <HelpField id="pipeline.config.haltPipelineOnFailure" />, | ||
}, | ||
{ | ||
label: 'halt this branch of the pipeline', | ||
value: 'stop', | ||
help: <HelpField id="pipeline.config.haltBranchOnFailure" />, | ||
}, | ||
{ | ||
label: 'halt this branch and fail the pipeline once other branches complete', | ||
value: 'faileventual', | ||
help: <HelpField id="pipeline.config.haltBranchOnFailureFailPipeline" />, | ||
}, | ||
{ | ||
label: 'ignore the failure', | ||
value: 'ignore', | ||
help: <HelpField id="pipeline.config.ignoreFailure" />, | ||
}, | ||
]; | ||
|
||
const getFailureOption = () => { | ||
let initValue = 'fail'; | ||
if (props.completeOtherBranchesThenFail === true) { | ||
initValue = 'faileventual'; | ||
} else if (props.failPipeline === true && props.continuePipeline === false) { | ||
initValue = 'fail'; | ||
} else if (props.failPipeline === false && props.continuePipeline === false) { | ||
initValue = 'stop'; | ||
} else if (props.failPipeline === false && props.continuePipeline === true) { | ||
initValue = 'ignore'; | ||
} | ||
return initValue; | ||
}; | ||
|
||
const failureOptionChanged = (value: string) => { | ||
if (value === 'fail') { | ||
props.updateStageField({ | ||
failPipeline: true, | ||
continuePipeline: false, | ||
completeOtherBranchesThenFail: false, | ||
}); | ||
} else if (value === 'stop') { | ||
props.updateStageField({ | ||
failPipeline: false, | ||
continuePipeline: false, | ||
completeOtherBranchesThenFail: false, | ||
}); | ||
} else if (value === 'ignore') { | ||
props.updateStageField({ | ||
failPipeline: false, | ||
continuePipeline: true, | ||
completeOtherBranchesThenFail: false, | ||
}); | ||
} else if (value === 'faileventual') { | ||
props.updateStageField({ | ||
failPipeline: false, | ||
continuePipeline: true, | ||
completeOtherBranchesThenFail: true, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<StageConfigField label="If stage fails"> | ||
<RadioButtonInput | ||
inputClassName={'override-failure-radio-input'} | ||
options={overrideFailureOptions} | ||
value={getFailureOption()} | ||
onChange={(e: any) => failureOptionChanged(e.target.value)} | ||
/> | ||
</StageConfigField> | ||
); | ||
}; |
57 changes: 0 additions & 57 deletions
57
...ts/modules/core/src/pipeline/config/stages/overrideFailure/overrideFailure.component.html
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
...ipts/modules/core/src/pipeline/config/stages/overrideFailure/overrideFailure.component.js
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
app/scripts/modules/core/src/pipeline/config/stages/overrideFailure/overrideFailure.less
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,5 @@ | ||
.override-failure-radio-input { | ||
.inline.clickable { | ||
width: 100%; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...scripts/modules/core/src/pipeline/config/stages/overrideFailure/overrideFailure.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,15 @@ | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
|
||
import { OverrideFailure } from './OverrideFailure'; | ||
|
||
export const OVERRRIDE_FAILURE = 'spinnaker.core.pipeline.stage.overrideFailure'; | ||
module(OVERRRIDE_FAILURE, []).component( | ||
'overrideFailure', | ||
react2angular(OverrideFailure, [ | ||
'failPipeline', | ||
'continuePipeline', | ||
'completeOtherBranchesThenFail', | ||
'updateStageField', | ||
]), | ||
); |
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