Merge pull request #2641 from charltonaustin/adding_build_trigger_for_custom_git_repository_fails_145071887

fix(custom git trigger): fixed init
This commit is contained in:
Charlton Austin 2017-05-15 14:32:29 -05:00 committed by GitHub
commit 298eed11ad
2 changed files with 15 additions and 4 deletions

View file

@ -31,7 +31,7 @@
<div class="col-lg-7 col-md-7 col-sm-12 main-col">
<h3>Select build context directory</h3>
<strong>Please select the build context directory under the git repository:</strong>
<input class="form-control" type="text" placeholder="/"
<input class="form-control" type="text"
ng-model="$ctrl.config.context"
ng-pattern="/^($|\/|\/.+)/">
</div>
@ -50,7 +50,7 @@
<div class="col-lg-7 col-md-7 col-sm-12 main-col">
<h3>Select dockerfile path</h3>
<strong>Please select the build context directory under the git repository:</strong>
<input class="form-control" type="text" placeholder="{{ $ctrl.config.context }}"
<input class="form-control" type="text"
ng-model="$ctrl.config.dockerfile_path"
ng-pattern="/^($|\/|\/.+)/">
</div>

View file

@ -1,4 +1,4 @@
import { Input, Output, Component, EventEmitter, OnChanges, SimpleChanges } from 'ng-metadata/core';
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from "ng-metadata/core";
/**
@ -13,12 +13,23 @@ export class ManageTriggerCustomGitComponent implements OnChanges {
// FIXME: Use one-way data binding
@Input('=') public trigger: {config: any};
@Output() public activateTrigger: EventEmitter<{config: any, pull_robot?: any}> = new EventEmitter();
private config: any = {};
private config: any = {"context": "/", "dockerfile_path": "/Dockerfile"};
private currentState: any | null;
public ngOnChanges(changes: SimpleChanges): void {
if (changes['trigger'] !== undefined) {
this.config = Object.assign({}, changes['trigger'].currentValue.config);
}
if (this.config.context === "") {
this.config.context = "/";
}
if (this.config.dockerfile_path === "") {
if (this.config.context.endsWith("/")) {
this.config.dockerfile_path = this.config.context + "Dockerfile";
} else {
this.config.dockerfile_path = this.config.context + "/Dockerfile";
}
}
}
}