Skip to content

Commit

Permalink
fix(core/pipeline): fix type mismatch in pipeline trigger, broken web…
Browse files Browse the repository at this point in the history
…hook trigger (#7018)
  • Loading branch information
erikmunson committed May 17, 2019
1 parent 4f4c32b commit 80af468
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export class BaseTrigger extends React.Component<IBaseTriggerConfigProps, IBaseT
};
}

public componentDidMount(): void {
public componentDidMount() {
if (SETTINGS.feature.fiatEnabled) {
Observable.fromPromise(ServiceAccountReader.getServiceAccounts())
.takeUntil(this.destroy$)
.subscribe(serviceAccounts => this.setState({ serviceAccounts }));
}
}

public componentWillUnmount(): void {
public componentWillUnmount() {
this.destroy$.next();
}

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

import { Observable } from 'rxjs';
import { Observable, Subject } from 'rxjs';

import { ApplicationReader } from 'core/application/service/ApplicationReader';
import { BaseTrigger } from 'core/pipeline';
import { Application, ApplicationReader } from 'core/application';
import { BaseTrigger, PipelineConfigService } from 'core/pipeline';
import { IPipeline, IPipelineTrigger } from 'core/domain';
import { PipelineConfigService } from 'core/pipeline/config/services/PipelineConfigService';
import { Omit } from 'core/presentation';
import { Checklist } from 'core/forms';
import { Application } from '@spinnaker/core';
import { Subject } from 'rxjs/Subject';

type IPipelineTriggerConfig = Omit<IPipelineTrigger, 'parentExecution' | 'parentPipelineId' | 'user' | 'rebake'>;

export interface IPipelineTriggerConfigProps {
status: string[];
trigger: IPipelineTrigger;
application: Application;
pipelineId: string;
triggerUpdated: (trigger: IPipelineTrigger) => void;
triggerUpdated: (trigger: IPipelineTriggerConfig) => void;
}

export interface IPipelineTriggerState {
applications: string[];
pipelines: IPipeline[];
pipelinesLoaded: boolean;
useDefaultParameters: { [k: string]: boolean };
userSuppliedParameters: { [k: string]: string };
}

export class PipelineTrigger extends React.Component<IPipelineTriggerConfigProps, IPipelineTriggerState> {
private destroy$ = new Subject();
private statusOptions = ['successful', 'failed', 'canceled'];

constructor(props: IPipelineTriggerConfigProps) {
super(props);

this.state = {
applications: [],
pipelines: [],
pipelinesLoaded: false,
useDefaultParameters: {},
userSuppliedParameters: {},
};
}
public state: IPipelineTriggerState = {
applications: [],
pipelines: [],
pipelinesLoaded: false,
};

public componentDidMount = () => {
public componentDidMount() {
Observable.fromPromise(ApplicationReader.listApplications())
.takeUntil(this.destroy$)
.subscribe(
applications => this.setState({ applications: applications.map(a => a.name).sort() }),
() => this.setState({ applications: [] }),
);

const { application } = this.props.trigger;
const { application, status } = this.props.trigger;
this.onUpdateTrigger({
application: application || this.props.application.name,
status: status || [],
});

this.init(application);
};
}

public componentWillUnmount() {
this.destroy$.next();
}

private init = (application: string) => {
const { pipelineId, trigger } = this.props;
Expand All @@ -78,7 +74,7 @@ export class PipelineTrigger extends React.Component<IPipelineTriggerConfigProps
}
};

private onUpdateTrigger = (update: any) => {
private onUpdateTrigger = (update: Partial<IPipelineTriggerConfig>) => {
this.props.triggerUpdated &&
this.props.triggerUpdated({
...this.props.trigger,
Expand Down Expand Up @@ -129,7 +125,7 @@ export class PipelineTrigger extends React.Component<IPipelineTriggerConfigProps
inline={true}
items={new Set(this.statusOptions)}
checked={new Set(status)}
onChange={(s: Set<string>) => this.onUpdateTrigger({ status: s })}
onChange={(s: Set<string>) => this.onUpdateTrigger({ status: Array.from(s) })}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export interface IWebhookTriggerProps {
}

export class WebhookTrigger extends React.Component<IWebhookTriggerProps> {
constructor(props: IWebhookTriggerProps) {
super(props);
}

private WebhookTriggerContents() {
private WebhookTriggerContents = () => {
const { trigger } = this.props;
const { source, type } = trigger;
const p = trigger.payloadConstraints || {};
Expand Down Expand Up @@ -61,7 +57,7 @@ export class WebhookTrigger extends React.Component<IWebhookTriggerProps> {
</div>
</>
);
}
};

private onUpdateTrigger = (update: any) => {
this.props.triggerUpdated &&
Expand Down

0 comments on commit 80af468

Please sign in to comment.