Skip to content

Commit b258a62

Browse files
sguiheuxbnjjj
authored andcommitted
fix (ui): fix payload on run again (#1222)
1 parent de947e6 commit b258a62

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

ui/src/app/shared/workflow/node/run/node.run.param.component.ts

+20-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {AutoUnsubscribe} from '../../../decorator/autoUnsubscribe';
1818
styleUrls: ['./node.run.param.scss']
1919
})
2020
@AutoUnsubscribe()
21-
export class WorkflowNodeRunParamComponent implements OnInit {
21+
export class WorkflowNodeRunParamComponent {
2222

2323
@ViewChild('runWithParamModal')
2424
runWithParamModal: ModalTemplate<boolean, boolean, void>;
@@ -30,10 +30,13 @@ export class WorkflowNodeRunParamComponent implements OnInit {
3030
@Input() workflow: Workflow;
3131
@Input('nodeToRun')
3232
set nodeToRun (data: WorkflowNode) {
33-
this._nodeToRun = cloneDeep(data);
34-
this.updateDefaultPipelineParameters();
35-
if (this._nodeToRun.context) {
36-
this.payloadString = JSON.stringify(this._nodeToRun.context.default_payload);
33+
if (data) {
34+
this._nodeToRun = cloneDeep(data);
35+
this.updateDefaultPipelineParameters();
36+
if (this._nodeToRun.context) {
37+
this.payloadString = JSON.stringify(this._nodeToRun.context.default_payload);
38+
}
39+
this.getPipeline();
3740
}
3841
};
3942
get nodeToRun(): WorkflowNode {
@@ -59,16 +62,19 @@ export class WorkflowNodeRunParamComponent implements OnInit {
5962
};
6063
}
6164

62-
ngOnInit(): void {
63-
this.pipelineSubscription = this._pipStore.getPipelines(this.project.key, this.nodeToRun.pipeline.name).subscribe(ps => {
64-
let pipkey = this.project.key + '-' + this.nodeToRun.pipeline.name;
65-
let pip = ps.get(pipkey);
66-
if (pip) {
67-
if (pip.last_modified === this.nodeToRun.pipeline.last_modified) {
68-
this.isSync = true;
65+
getPipeline(): void {
66+
if (!this.pipelineSubscription) {
67+
this.pipelineSubscription = this._pipStore.getPipelines(this.project.key, this.nodeToRun.pipeline.name).subscribe(ps => {
68+
let pipkey = this.project.key + '-' + this.nodeToRun.pipeline.name;
69+
let pip = ps.get(pipkey);
70+
if (pip) {
71+
if (pip.last_modified === this.nodeToRun.pipeline.last_modified) {
72+
this.isSync = true;
73+
}
6974
}
70-
}
71-
})
75+
});
76+
}
77+
7278
}
7379

7480
show(): void {

ui/src/app/shared/workflow/node/workflow.node.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
(nameWarning.hooks.length > 0 || nameWarning.joinTriggers.length > 0 || nameWarning.triggers.length > 0)">
4848
{{ 'workflow_node_name_warning' | translate }}
4949
</span>
50-
<button class="ui mini icon right floated green button" (click)="rename()"><i class="check icon"></i></button>
50+
<button class="ui mini icon right floated green button" (click)="rename()" [class.loading]="loading" [disabled]="loading"><i class="check icon"></i></button>
5151
</div>
5252
</div>
5353
</div>
5454

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

ui/src/app/shared/workflow/node/workflow.node.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ $boxWidth: 155px;
8989
margin-top: 10px;
9090
font-size: 2.2em;
9191
&.icon.build {
92-
margin-left: 5px;
92+
margin-left: 3px;
9393
margin-top: 7px;
9494
font-size: 1.2em;
9595
}

ui/src/app/views/workflow/run/workflow.run.component.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { WorkflowNode } from '../../../model/workflow.model';
12
import {Component, NgZone, OnDestroy, OnInit, ViewChild} from '@angular/core';
23
import {ActivatedRoute, Router} from '@angular/router';
34
import {Project} from '../../../model/project.model';
@@ -11,6 +12,7 @@ import {AutoUnsubscribe} from '../../../shared/decorator/autoUnsubscribe';
1112
import {WorkflowStore} from '../../../service/workflow/workflow.store';
1213
import {WorkflowRunService} from '../../../service/workflow/run/workflow.run.service';
1314
import {WorkflowNodeRunParamComponent} from '../../../shared/workflow/node/run/node.run.param.component';
15+
import {cloneDeep} from 'lodash';
1416

1517
@Component({
1618
selector: 'app-workflow-run',
@@ -31,6 +33,8 @@ export class WorkflowRunComponent implements OnDestroy, OnInit {
3133
version: string;
3234
direction: string;
3335

36+
nodeToRun: WorkflowNode;
37+
3438
pipelineStatusEnum = PipelineStatus;
3539

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

8084
relaunch() {
8185
if (this.runWithParamComponent && this.runWithParamComponent.show) {
86+
let rootNodeRun = this.workflowRun.nodes[this.workflowRun.workflow.root.id][0];
87+
this.nodeToRun = cloneDeep(this.workflowRun.workflow.root);
88+
if (rootNodeRun.hook_event) {
89+
this.nodeToRun.context.default_payload = rootNodeRun.hook_event.payload;
90+
this.nodeToRun.context.default_pipeline_parameters = rootNodeRun.hook_event.pipeline_parameter;
91+
}
92+
if (rootNodeRun.manual) {
93+
this.nodeToRun.context.default_payload = rootNodeRun.manual.payload;
94+
this.nodeToRun.context.default_pipeline_parameters = rootNodeRun.manual.pipeline_parameter;
95+
}
8296
this.runWithParamComponent.show();
8397
}
8498
}

ui/src/app/views/workflow/run/workflow.run.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
#workflowNodeRunParam
2525
[project]="project"
2626
[workflow]="workflowRun.workflow"
27-
[nodeToRun]="workflowRun.workflow.root">
27+
[nodeToRun]="nodeToRun">
2828
</app-workflow-node-run-param>

0 commit comments

Comments
 (0)