Skip to content

Commit

Permalink
fix (ui): fix payload on run again (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux authored and bnjjj committed Oct 3, 2017
1 parent de947e6 commit b258a62
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
34 changes: 20 additions & 14 deletions ui/src/app/shared/workflow/node/run/node.run.param.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {AutoUnsubscribe} from '../../../decorator/autoUnsubscribe';
styleUrls: ['./node.run.param.scss']
})
@AutoUnsubscribe()
export class WorkflowNodeRunParamComponent implements OnInit {
export class WorkflowNodeRunParamComponent {

@ViewChild('runWithParamModal')
runWithParamModal: ModalTemplate<boolean, boolean, void>;
Expand All @@ -30,10 +30,13 @@ export class WorkflowNodeRunParamComponent implements OnInit {
@Input() workflow: Workflow;
@Input('nodeToRun')
set nodeToRun (data: WorkflowNode) {
this._nodeToRun = cloneDeep(data);
this.updateDefaultPipelineParameters();
if (this._nodeToRun.context) {
this.payloadString = JSON.stringify(this._nodeToRun.context.default_payload);
if (data) {
this._nodeToRun = cloneDeep(data);
this.updateDefaultPipelineParameters();
if (this._nodeToRun.context) {
this.payloadString = JSON.stringify(this._nodeToRun.context.default_payload);
}
this.getPipeline();
}
};
get nodeToRun(): WorkflowNode {
Expand All @@ -59,16 +62,19 @@ export class WorkflowNodeRunParamComponent implements OnInit {
};
}

ngOnInit(): void {
this.pipelineSubscription = this._pipStore.getPipelines(this.project.key, this.nodeToRun.pipeline.name).subscribe(ps => {
let pipkey = this.project.key + '-' + this.nodeToRun.pipeline.name;
let pip = ps.get(pipkey);
if (pip) {
if (pip.last_modified === this.nodeToRun.pipeline.last_modified) {
this.isSync = true;
getPipeline(): void {
if (!this.pipelineSubscription) {
this.pipelineSubscription = this._pipStore.getPipelines(this.project.key, this.nodeToRun.pipeline.name).subscribe(ps => {
let pipkey = this.project.key + '-' + this.nodeToRun.pipeline.name;
let pip = ps.get(pipkey);
if (pip) {
if (pip.last_modified === this.nodeToRun.pipeline.last_modified) {
this.isSync = true;
}
}
}
})
});
}

}

show(): void {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/shared/workflow/node/workflow.node.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
(nameWarning.hooks.length > 0 || nameWarning.joinTriggers.length > 0 || nameWarning.triggers.length > 0)">
{{ 'workflow_node_name_warning' | translate }}
</span>
<button class="ui mini icon right floated green button" (click)="rename()"><i class="check icon"></i></button>
<button class="ui mini icon right floated green button" (click)="rename()" [class.loading]="loading" [disabled]="loading"><i class="check icon"></i></button>
</div>
</div>
</div>

<!-- area to display application name -->
<div class="footer" *ngIf="node.context.application_id && node.context.application_id > 0">
<div class="footer" *ngIf="node.context.application_id && node.context.application_id > 0 && !displayInputName">
<p class="ellipsis">{{node.context.application.name}}</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/workflow/node/workflow.node.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $boxWidth: 155px;
margin-top: 10px;
font-size: 2.2em;
&.icon.build {
margin-left: 5px;
margin-left: 3px;
margin-top: 7px;
font-size: 1.2em;
}
Expand Down
14 changes: 14 additions & 0 deletions ui/src/app/views/workflow/run/workflow.run.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WorkflowNode } from '../../../model/workflow.model';
import {Component, NgZone, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Project} from '../../../model/project.model';
Expand All @@ -11,6 +12,7 @@ import {AutoUnsubscribe} from '../../../shared/decorator/autoUnsubscribe';
import {WorkflowStore} from '../../../service/workflow/workflow.store';
import {WorkflowRunService} from '../../../service/workflow/run/workflow.run.service';
import {WorkflowNodeRunParamComponent} from '../../../shared/workflow/node/run/node.run.param.component';
import {cloneDeep} from 'lodash';

@Component({
selector: 'app-workflow-run',
Expand All @@ -31,6 +33,8 @@ export class WorkflowRunComponent implements OnDestroy, OnInit {
version: string;
direction: string;

nodeToRun: WorkflowNode;

pipelineStatusEnum = PipelineStatus;

constructor(private _activatedRoute: ActivatedRoute, private _authStore: AuthentificationStore,
Expand Down Expand Up @@ -79,6 +83,16 @@ export class WorkflowRunComponent implements OnDestroy, OnInit {

relaunch() {
if (this.runWithParamComponent && this.runWithParamComponent.show) {
let rootNodeRun = this.workflowRun.nodes[this.workflowRun.workflow.root.id][0];
this.nodeToRun = cloneDeep(this.workflowRun.workflow.root);
if (rootNodeRun.hook_event) {
this.nodeToRun.context.default_payload = rootNodeRun.hook_event.payload;
this.nodeToRun.context.default_pipeline_parameters = rootNodeRun.hook_event.pipeline_parameter;
}
if (rootNodeRun.manual) {
this.nodeToRun.context.default_payload = rootNodeRun.manual.payload;
this.nodeToRun.context.default_pipeline_parameters = rootNodeRun.manual.pipeline_parameter;
}
this.runWithParamComponent.show();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/views/workflow/run/workflow.run.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
#workflowNodeRunParam
[project]="project"
[workflow]="workflowRun.workflow"
[nodeToRun]="workflowRun.workflow.root">
[nodeToRun]="nodeToRun">
</app-workflow-node-run-param>

0 comments on commit b258a62

Please sign in to comment.