From 4c98c9c16379a4947c2a7fe5c2cf64985a5767d0 Mon Sep 17 00:00:00 2001 From: Guiheux Steven Date: Thu, 18 Jun 2020 16:46:15 +0200 Subject: [PATCH] fix(api, ui): synchronous ended child workflow + navigation parent/child (#5261) --- engine/api/workflow_run.go | 11 ++++++++++- ui/Makefile | 3 +++ .../app/views/workflow/run/workflow.run.component.ts | 12 ++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/engine/api/workflow_run.go b/engine/api/workflow_run.go index 6f94cc0af9..2bbb477b91 100644 --- a/engine/api/workflow_run.go +++ b/engine/api/workflow_run.go @@ -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 @@ -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 { diff --git a/ui/Makefile b/ui/Makefile index ca0c40be56..4ce14bfa1e 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -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 diff --git a/ui/src/app/views/workflow/run/workflow.run.component.ts b/ui/src/app/views/workflow/run/workflow.run.component.ts index c9907ab6e5..fa29acda74 100644 --- a/ui/src/app/views/workflow/run/workflow.run.component.ts +++ b/ui/src/app/views/workflow/run/workflow.run.component.ts @@ -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'; @@ -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(