diff --git a/app/scripts/modules/core/src/help/help.contents.ts b/app/scripts/modules/core/src/help/help.contents.ts index 41a61c2f17b..67cbac439e7 100644 --- a/app/scripts/modules/core/src/help/help.contents.ts +++ b/app/scripts/modules/core/src/help/help.contents.ts @@ -79,6 +79,8 @@ const helpContents: { [key: string]: string } = { 'pipeline.config.checkPreconditions.failPipeline': `

Checked - the overall pipeline will fail whenever this precondition is false.

Unchecked - the overall pipeline will continue executing but this particular branch will stop.

`, + 'pipeline.config.checkPreconditions.failureMessage': ` +

This failure message will be shown to the user if the precondition evaluates to false.

`, 'pipeline.config.checkPreconditions.expectedSize': 'Number of server groups in the selected cluster', 'pipeline.config.checkPreconditions.expression': `

Value must evaluate to "true".

diff --git a/app/scripts/modules/core/src/pipeline/config/preconditions/types/expression/additionalFields.html b/app/scripts/modules/core/src/pipeline/config/preconditions/types/expression/additionalFields.html index 9ebf2b10ef1..c4787b413ac 100644 --- a/app/scripts/modules/core/src/pipeline/config/preconditions/types/expression/additionalFields.html +++ b/app/scripts/modules/core/src/pipeline/config/preconditions/types/expression/additionalFields.html @@ -16,4 +16,13 @@ + +
+
+ Failure Message +
+
+ +
+
diff --git a/app/scripts/modules/core/src/pipeline/config/stages/checkPreconditions/CheckPreconditionsExecutionDetails.tsx b/app/scripts/modules/core/src/pipeline/config/stages/checkPreconditions/CheckPreconditionsExecutionDetails.tsx index 692380e4094..7c6028e2aa1 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/checkPreconditions/CheckPreconditionsExecutionDetails.tsx +++ b/app/scripts/modules/core/src/pipeline/config/stages/checkPreconditions/CheckPreconditionsExecutionDetails.tsx @@ -2,18 +2,22 @@ import * as React from 'react'; import { get } from 'lodash'; import { StageFailureMessage } from 'core/pipeline'; + import { ExecutionDetailsSection, IExecutionDetailsSectionProps } from '../common'; import { robotToHuman } from 'core/presentation/robotToHumanFilter/robotToHuman.filter'; export function CheckPreconditionsExecutionDetails(props: IExecutionDetailsSectionProps) { const context = get(props.stage, 'context.context', {} as any); + const userFailureMessage = context.failureMessage; + const failureMessage = props.stage.failureMessage; + const stageFailureMessage = failureMessage == null ? userFailureMessage : failureMessage; return (
{Object.keys(context) - .filter(key => key !== 'expression' && context[key] !== null) + .filter(key => !['expression', 'failureMessage'].includes(key) && context[key] !== null) .map(key => (
{robotToHuman(key)}
@@ -27,7 +31,7 @@ export function CheckPreconditionsExecutionDetails(props: IExecutionDetailsSecti
- +
); } diff --git a/app/scripts/modules/core/src/pipeline/details/StageFailureMessage.tsx b/app/scripts/modules/core/src/pipeline/details/StageFailureMessage.tsx index be0f5f2579e..dfc519ac11b 100644 --- a/app/scripts/modules/core/src/pipeline/details/StageFailureMessage.tsx +++ b/app/scripts/modules/core/src/pipeline/details/StageFailureMessage.tsx @@ -23,6 +23,10 @@ export interface IStageFailureMessageState { isFailed?: boolean; } +export enum StageFailureMessages { + NO_REASON_PROVIDED = 'No reason provided.', +} + @UIRouterContext export class StageFailureMessage extends React.Component { public static defaultProps: Partial = { @@ -73,9 +77,11 @@ export class StageFailureMessage extends React.Component + ) : ( - messages.map((m, i) => ) + messages.map((m, i) => ( + + )) ); if (displayMessages) {