Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Issue argoproj#40: Added fallback values for form in multiple-service-launch-panel

* Issue argoproj#40: Added the template index for fallback val and changed the prop name to 'revision'

* Issue argoproj#40: Passed in the template itself to provide the fallback val
  • Loading branch information
felixApplatix authored and wokeGit committed Nov 20, 2017
1 parent aa26f2d commit e58ff2f
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class MultipleServiceLaunchPanelComponent {
if (resubmitFailedParameters) { // resubmit failed
val = resubmitFailedParameters[property];
} else if (templateInputParams[property] && templateInputParams[property].hasOwnProperty('default')) {
val = this.setParamValue(templateInputParams[property]['default']);
val = this.setParamValue(templateInputParams[property]['default'], template);
required = false;
}
newForm.addControl(property, new FormControl(val, required ? Validators.required : null));
Expand All @@ -352,12 +352,12 @@ export class MultipleServiceLaunchPanelComponent {
}

// if default value for parameter starts and ends with %%, replace the value with corresponding commits parameter
private setParamValue(parameterValue: string) {
private setParamValue(parameterValue: string, template: Template) {
let vTemp = parameterValue;
this.session = {
commit: this.commit.revision || this.getFallbackTemplateValue('commit'),
repo: this.commit.repo || this.getFallbackTemplateValue('repo'),
branch: this.commit.branch || this.getFallbackTemplateValue('branch')
commit: this.commit.revision || template.revision,
repo: this.commit.repo || template.repo,
branch: this.commit.branch || template.branch
};

// this is required to GUI-1367 launch a workflow using the workflow instance's exported artifact
Expand All @@ -376,13 +376,6 @@ export class MultipleServiceLaunchPanelComponent {
return this.session[parameterValue.substring(parameterValue.indexOf('.') + 1).toString()] || vTemp;
}

private getFallbackTemplateValue(prop: string) {
if (this.templatesToSubmit.length === 1 && this.templatesToSubmit[0][prop]) {
return this.templatesToSubmit[0][prop];
}
return;
}

private resubmitTask(task, runPartial = false): any {
if (runPartial) {
task.parameters = this.listParameters(this.allForms.controls[0]['controls']);
Expand Down

0 comments on commit e58ff2f

Please sign in to comment.