Skip to content

Commit

Permalink
fix(api, ui): synchronous ended child workflow + navigation parent/ch…
Browse files Browse the repository at this point in the history
…ild (#5261)
  • Loading branch information
sguiheux authored Jun 18, 2020
1 parent a97f6a7 commit 4c98c9c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
11 changes: 10 additions & 1 deletion engine/api/workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,6 @@ func (api *API) initWorkflowRun(ctx context.Context, projKey string, wf *sdk.Wor
report.Merge(ctx, r)
return
}

workflow.ResyncNodeRunsWithCommits(ctx, api.mustDB(), api.Cache, *p, report)

// Purge workflow run
Expand All @@ -1023,6 +1022,16 @@ func (api *API) initWorkflowRun(ctx context.Context, projKey string, wf *sdk.Wor
log.Error(ctx, "workflow.PurgeWorkflowRun> error %v", err)
}
}, api.PanicDump())

// Update parent
for i := range report.WorkflowRuns() {
run := &report.WorkflowRuns()[i]
reportParent, err := updateParentWorkflowRun(ctx, api.mustDB, api.Cache, run)
if err != nil {
log.Error(ctx, "unable to update parent workflow run: %v", err)
}
go WorkflowSendEvent(context.Background(), api.mustDB(), api.Cache, *p, reportParent)
}
}

func failInitWorkflowRun(ctx context.Context, db *gorp.DbMap, wfRun *sdk.WorkflowRun, err error) *workflow.ProcessorReport {
Expand Down
3 changes: 3 additions & 0 deletions ui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ build: $(FILES_UI) $(INDEX) ui.tar.gz

ui.tar.gz:
tar cfz ui.tar.gz dist

lintfix:
./node_modules/.bin/ng lint --fix
12 changes: 10 additions & 2 deletions ui/src/app/views/workflow/run/workflow.run.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Select, Store } from '@ngxs/store';
import { PipelineStatus, SpawnInfo } from 'app/model/pipeline.model';
import { Project } from 'app/model/project.model';
import { WorkflowRun } from 'app/model/workflow.run.model';
import { NotificationService } from 'app/service/notification/notification.service';
import { RouterService } from 'app/service/router/router.service';
import { WorkflowStore } from 'app/service/workflow/workflow.store';
import { AutoUnsubscribe } from 'app/shared/decorator/autoUnsubscribe';
import { ProjectState } from 'app/store/project.state';
Expand Down Expand Up @@ -55,13 +56,20 @@ export class WorkflowRunComponent implements OnInit {
private _notification: NotificationService,
private _translate: TranslateService,
private _titleService: Title,
private _cd: ChangeDetectorRef
private _cd: ChangeDetectorRef,
private _router: Router,
private _routerService: RouterService
) {
this.project = this._store.selectSnapshot(ProjectState.projectSnapshot);
this.workflowName = this._store.selectSnapshot(WorkflowState.workflowSnapshot).name;
this._store.dispatch(new ChangeToRunView({}));

this.paramsSub = this._activatedRoute.params.subscribe(p => {
let allParamsSnapshot = this._routerService.getRouteSnapshotParams({}, this._router.routerState.snapshot.root);
if (allParamsSnapshot['workflowName'] !== this.workflowName) {
// If workflow change, component will be destroy by parent
return;
}
this.workflowRunData = {};
this._cd.markForCheck();
this._store.dispatch(
Expand Down

0 comments on commit 4c98c9c

Please sign in to comment.