Skip to content

Commit

Permalink
feat(webhooks): preconfigured webhook params (#4669)
Browse files Browse the repository at this point in the history
adds support for preconfigured webhook parameters. these parameters can
be set in orca's config and are then exposed to users. instead of
expecting users to fillout an entire payload, these parameters can be
used to expose the important parts and abstract the other configuration
away.
  • Loading branch information
ethanfrogers authored and ajordens committed Jan 17, 2018
1 parent 3155b2f commit 2311696
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ <h5>Webhook Stage Configuration</h5>
<dd>{{ctrl.stage.context.statusEndpoint}}</dd>
</dl>
</div>
<div class="col-md-12" ng-if="ctrl.stage.context.parameterValues">
<h5>Parameters</h5>
<dl class="dl-narrow dl-horizontal">
<dt ng-repeat-start="(key, val) in ctrl.stage.context.parameterValues">{{key}}</dt>
<dd ng-repeat-end>{{val}}</dd>
</dl>
</div>
</div>
<stage-failure-message stage="ctrl.stage" is-failed="ctrl.stage.isFailed" message="ctrl.getException(stage) || ctrl.failureMessage"></stage-failure-message>
<div class="well alert-info" ng-if="ctrl.stage.context.progressMessage || ctrl.stage.status">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
</ui-select-choices>
</ui-select>
</stage-config-field>
<stage-config-field label="Parameters"
ng-if="$ctrl.parameters.length">
<div class="form-group" ng-repeat="parameter in $ctrl.parameters | orderBy:'name'">
<div class="col-md-3 sm-label-right">
<b class="break-word">{{ parameter.label }}</b>
<help-field content="{{parameter.description}}" ng-if="parameter.description"></help-field>
</div>
<div class="col-md-5">
<input ng-model="$ctrl.stage.parameterValues[parameter.name]" type="text" class="form-control input-sm"/>
</div>
</div>
</stage-config-field>
<stage-config-field label="Payload"
help-key="pipeline.config.webhook.payload"
ng-if="$ctrl.stage.method !== 'GET' && $ctrl.stage.method !== 'HEAD' && $ctrl.displayField('payload')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ export interface ICustomHeader {
value: string;
}

interface IWebhookParameter {
name: string;
label: string;
description?: string;
type: string;
defaultValue?: string;
}

interface IPreconfiguredWebhook {
type: string;
label: string;
noUserConfigurableFields: boolean
description?: string;
waitForCompletion?: boolean
preconfiguredProperties?: string[];
parameters?: IWebhookParameter[];
}

export class WebhookStage implements IController {
Expand All @@ -36,6 +45,7 @@ export class WebhookStage implements IController {
public methods: string[];
public preconfiguredProperties: string[];
public noUserConfigurableFields: boolean;
public parameters: IWebhookParameter[];

constructor(public stage: any,
private jsonUtilityService: JsonUtilityService,
Expand All @@ -60,7 +70,18 @@ export class WebhookStage implements IController {
this.preconfiguredProperties = stageConfig.configuration.preconfiguredProperties || [];
this.noUserConfigurableFields = stageConfig.configuration.noUserConfigurableFields;
this.viewState.waitForCompletion = stageConfig.configuration.waitForCompletion || this.viewState.waitForCompletion;
this.parameters = stageConfig.configuration.parameters || [];
}

if (this.parameters.length && !this.stage.parameterValues) {
this.stage.parameterValues = {};
}

this.parameters.forEach((config: any) => {
if (!(config.name in this.stage.parameterValues) && (config.defaultValue !== null)) {
this.stage.parameterValues[config.name] = config.defaultValue;
}
});
}

public updatePayload(): void {
Expand Down Expand Up @@ -146,7 +167,8 @@ module(WEBHOOK_STAGE, [
configuration: {
preconfiguredProperties: preconfiguredWebhook.preconfiguredProperties,
waitForCompletion: preconfiguredWebhook.waitForCompletion,
noUserConfigurableFields: preconfiguredWebhook.noUserConfigurableFields
noUserConfigurableFields: preconfiguredWebhook.noUserConfigurableFields,
parameters: preconfiguredWebhook.parameters
}
}))
})
Expand Down

0 comments on commit 2311696

Please sign in to comment.