77 OnInit ,
88 Output
99} from '@angular/core' ;
10- import { Store } from '@ngxs/store' ;
10+ import { Select , Store } from '@ngxs/store' ;
1111import { IPopup } from '@richardlt/ng2-semantic-ui' ;
1212import { PipelineStatus } from 'app/model/pipeline.model' ;
1313import { Project } from 'app/model/project.model' ;
@@ -16,6 +16,8 @@ import { WorkflowNodeRun, WorkflowRun } from 'app/model/workflow.run.model';
1616import { AutoUnsubscribe } from 'app/shared/decorator/autoUnsubscribe' ;
1717import { ProjectState } from 'app/store/project.state' ;
1818import { WorkflowState , WorkflowStateModel } from 'app/store/workflow.state' ;
19+ import { Observable , Subscription } from 'rxjs' ;
20+ import { map } from 'rxjs/operators' ;
1921
2022@Component ( {
2123 selector : 'app-workflow-menu-wnode-edit' ,
@@ -32,9 +34,16 @@ export class WorkflowWNodeMenuEditComponent implements OnInit {
3234
3335 project : Project ;
3436 workflow : Workflow ;
37+ node : WNode ;
38+
39+
3540 workflowrun : WorkflowRun ;
41+ @Select ( WorkflowState . getSelectedWorkflowRun ( ) ) workflowRun$ : Observable < WorkflowRun > ;
42+ workflowRunSub : Subscription ;
43+
3644 noderun : WorkflowNodeRun ;
37- node : WNode ;
45+ nodeRunSub : Subscription ;
46+
3847 runnable : boolean ;
3948 readonly = true ;
4049
@@ -48,11 +57,36 @@ export class WorkflowWNodeMenuEditComponent implements OnInit {
4857
4958 let state : WorkflowStateModel = this . _store . selectSnapshot ( WorkflowState ) ;
5059 this . workflow = state . workflow ;
51- this . workflowrun = state . workflowRun ;
52- this . noderun = state . workflowNodeRun ;
5360 this . node = state . node ;
54- this . readonly = ! state . canEdit || ( ! ! this . workflow . from_template && ! ! this . workflow . from_repository ) ;
5561
62+
63+ this . workflowRunSub = this . workflowRun$ . subscribe ( wr => {
64+ if ( ! wr ) {
65+ return ;
66+ }
67+ if ( this . workflow . id !== wr . workflow_id ) {
68+ return ;
69+ }
70+ this . workflowrun = wr ;
71+ this . runnable = this . getCanBeRun ( ) ;
72+ this . _cd . markForCheck ( ) ;
73+ } ) ;
74+
75+ this . nodeRunSub = this . _store . select ( WorkflowState . nodeRunByNodeID )
76+ . pipe ( map ( filterFn => filterFn ( this . node . id ) ) ) . subscribe ( nodeRun => {
77+ if ( ! nodeRun ) {
78+ return ;
79+ }
80+ if ( this . noderun && this . noderun . status === nodeRun . status ) {
81+ return ;
82+ }
83+ this . noderun = nodeRun ;
84+ this . runnable = this . getCanBeRun ( ) ;
85+ this . _cd . markForCheck ( ) ;
86+ } ) ;
87+
88+
89+ this . readonly = ! state . canEdit || ( ! ! this . workflow . from_template && ! ! this . workflow . from_repository ) ;
5690 this . runnable = this . getCanBeRun ( ) ;
5791 this . _cd . markForCheck ( ) ;
5892 }
0 commit comments