Skip to content

Commit

Permalink
fix(ui): run workflow in the middle (#5077)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux authored Mar 24, 2020
1 parent 9c2ac89 commit dc99a29
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class WorkflowSidebarRunNodeComponent implements OnDestroy, OnInit {
});

this.nodeRunSubs = this.nodeRun$.subscribe( nrs => {
if (!nrs && !this.currentWorkflowNodeRun) {
if (!nrs) {
return;
}
// If event on same noderun with same status, check if tests or artifacts changed
Expand Down
14 changes: 9 additions & 5 deletions ui/src/app/shared/workflow/wnode/wnode.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import {
AddHookWorkflow,
AddJoinWorkflow,
AddNodeTriggerWorkflow,
OpenEditModal,
OpenEditModal, SelectWorkflowNode,
SelectWorkflowNodeRun,
UpdateWorkflow
} from 'app/store/workflow.action';
import { WorkflowState, WorkflowStateModel } from 'app/store/workflow.state';
import { Subscription } from 'rxjs';
import { finalize } from 'rxjs/operators';
import { finalize, tap } from 'rxjs/operators';

@Component({
selector: 'app-workflow-wnode',
Expand Down Expand Up @@ -107,13 +107,17 @@ export class WorkflowWNodeComponent implements OnInit {
if (this.workflow.previewMode || !popup) {
return;
}
popup.open();
if (this.currentNodeRun) {
if (!this.currentNodeRun) {
this._store.dispatch(new SelectWorkflowNode({
node: this.node
})).pipe(tap(popup.open));
} else {
this._store.dispatch(new SelectWorkflowNodeRun({
workflowNodeRun: this.currentNodeRun,
node: this.node
}));
})).pipe(tap(popup.open));
}

}

dblClickOnNode() {
Expand Down
5 changes: 5 additions & 0 deletions ui/src/app/store/workflow.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export class GetWorkflowNodeRun {
constructor(public payload: { projectKey: string, workflowName: string, num: number, nodeRunID: number }) { }
}

export class SelectWorkflowNode {
static readonly type = '[Workflow] Select Workflow Node';
constructor(public payload: { node: WNode }) { }
}

export class SelectWorkflowNodeRun {
static readonly type = '[Workflow] Select Workflow Node Run';
constructor(public payload: { workflowNodeRun: WorkflowNodeRun, node: WNode }) { }
Expand Down
15 changes: 15 additions & 0 deletions ui/src/app/store/workflow.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,21 @@ export class WorkflowState {
});
}

@Action(actionWorkflow.SelectWorkflowNode)
selectWorkflowNode(ctx: StateContext<WorkflowStateModel>, action: actionWorkflow.SelectWorkflowNode) {
const state = ctx.getState();
if (state.node && state.node.id === action.payload.node.id) {
return;
}
ctx.setState({
...state,
workflowNodeRun: null,
node: action.payload.node,
sidebar: WorkflowSidebarMode.RUNS
});
}


@Action(actionWorkflow.SelectWorkflowNodeRun)
selectWorkflowNodeRun(ctx: StateContext<WorkflowStateModel>, action: actionWorkflow.SelectWorkflowNodeRun) {
const state = ctx.getState();
Expand Down

0 comments on commit dc99a29

Please sign in to comment.