Skip to content

Commit

Permalink
fix(core/pipeline): Trigger pipeline validation when a trigger is upd…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
christopherthielen committed Jul 15, 2019
1 parent 4a8b341 commit ac2f61c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Formik, FormikProps, FormikErrors } from 'formik';

import { IStage, IPipeline } from 'core/domain';
import { IStage, IPipeline, ITrigger } from 'core/domain';
import { Application } from 'core/application';
import { LayoutProvider, ResponsiveFieldLayout, WatchValue } from 'core/presentation';

Expand All @@ -12,7 +12,7 @@ export interface IFormikStageConfigInjectedProps {
}

export type IContextualValidator = (
values: IStage,
values: IStage | ITrigger,
context: any,
) => FormikErrors<IStage> | Promise<FormikErrors<IStage>>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import Select, { Option } from 'react-select';
import * as classNames from 'classnames';

import { Application } from 'core/application';
import { IExpectedArtifact, IPipeline, ITrigger, ITriggerTypeConfig } from 'core/domain';
Expand Down Expand Up @@ -113,10 +114,11 @@ export class Trigger extends React.Component<ITriggerProps, ITriggerState> {
const { pipeline, trigger } = this.props;
const { TriggerContents } = this;
const fieldSetClassName = classNames({ 'templated-pipeline-item': trigger.inherited });

return (
<div className="row">
<div className="col-md-12">
<fieldset disabled={trigger.inherited} className={`templated-pipeline-item`}>
<fieldset disabled={trigger.inherited} className={fieldSetClassName}>
<div className="form-horizontal panel-pipeline-phase">
<div className="form-group row">
<div className="col-md-10">
Expand All @@ -143,7 +145,7 @@ export class Trigger extends React.Component<ITriggerProps, ITriggerState> {
{trigger.inherited ? (
<span className="templated-pipeline-item__status btn btn-sm btn-default">
<Tooltip value="From Template">
<i className="from-template fa fa-table"/>
<i className="from-template fa fa-table" />
</Tooltip>
<span className="visible-xl-inline">From Template</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ArtifactReferenceService } from 'core/artifact/ArtifactReferenceService
import { ExpectedArtifactService } from 'core/artifact/expectedArtifact.service';
import { Registry } from 'core/registry';
import { SETTINGS } from 'core/config/settings';
import { PipelineConfigValidator } from 'core/pipeline';

const angular = require('angular');

Expand Down Expand Up @@ -120,6 +121,7 @@ module.exports = angular

$scope.updateTrigger = function(index, changes) {
$scope.$applyAsync(() => {
PipelineConfigValidator.validatePipeline($scope.pipeline);
$scope.pipeline.triggers = $scope.pipeline.triggers.slice(0);
extend($scope.pipeline.triggers[index], changes);
if (SETTINGS.feature['artifactsRewrite']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ export class PipelineConfigValidator {
);
}
});
} else if (config && config.validateFn) {
validations.push(
$q<FormikErrors<IStage>>((resolve, reject) =>
Promise.resolve(config.validateFn(trigger, { pipeline })).then(resolve, reject),
).then((errors: FormikErrors<ITrigger>) => {
PipelineConfigValidator.flattenValues(errors).forEach(message => {
pipelineValidations.push(message);
});
}),
);
}
});
stages.forEach(stage => {
Expand Down

0 comments on commit ac2f61c

Please sign in to comment.