From 4620afdbc47204f57f15f5fb4e9e3d49dd17a81e Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Wed, 31 Jan 2024 09:36:45 -0500 Subject: [PATCH] [NIFI-12694] - Fix console errors when starting/stopping process groups (#8317) This closes #8317 --- .../flow-designer/state/flow/flow.actions.ts | 14 +++++++++++++- .../flow-designer/state/flow/flow.effects.ts | 14 ++++++-------- .../flow-designer/state/flow/flow.reducer.ts | 3 ++- .../app/pages/flow-designer/state/flow/index.ts | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts index a6c616670f..2135726913 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts @@ -68,7 +68,9 @@ import { UpdateConnectionSuccess, UpdatePositionsRequest, UploadProcessGroupRequest, - NavigateToQueueListing + NavigateToQueueListing, + StartProcessGroupResponse, + StopProcessGroupResponse } from './index'; import { StatusHistoryRequest } from '../../../../state/status-history'; @@ -495,6 +497,11 @@ export const startComponentSuccess = createAction( props<{ response: StartComponentResponse }>() ); +export const startProcessGroupSuccess = createAction( + `${CANVAS_PREFIX} Start Process Group Success`, + props<{ response: StartProcessGroupResponse }>() +); + export const stopComponent = createAction( `${CANVAS_PREFIX} Stop Component`, props<{ request: StopComponentRequest | StopProcessGroupRequest }>() @@ -510,6 +517,11 @@ export const stopComponentSuccess = createAction( props<{ response: StopComponentResponse }>() ); +export const stopProcessGroupSuccess = createAction( + `${CANVAS_PREFIX} Stop Process Group Success`, + props<{ response: StopProcessGroupResponse }>() +); + export const startCurrentProcessGroup = createAction(`${CANVAS_PREFIX} Start Current Process Group`); export const stopCurrentProcessGroup = createAction(`${CANVAS_PREFIX} Stop Current Process Group`); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts index 6b0ece8162..ef3bdc9b96 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts @@ -2039,7 +2039,7 @@ export class FlowEffects { this.flowService.startRemoteProcessGroupsInProcessGroup(request) ]).pipe( map(([startPgResponse]) => { - return FlowActions.startComponentSuccess({ + return FlowActions.startProcessGroupSuccess({ response: { type: request.type, component: startPgResponse @@ -2061,7 +2061,7 @@ export class FlowEffects { */ startCurrentProcessGroupSuccess$ = createEffect(() => this.actions$.pipe( - ofType(FlowActions.startComponentSuccess), + ofType(FlowActions.startProcessGroupSuccess), map((action) => action.response), concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)), filter(([response, currentPg]) => response.component.id === currentPg), @@ -2074,10 +2074,9 @@ export class FlowEffects { */ startProcessGroupSuccess$ = createEffect(() => this.actions$.pipe( - ofType(FlowActions.startComponentSuccess), + ofType(FlowActions.startProcessGroupSuccess), map((action) => action.response), concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)), - filter(([response]) => response.type === ComponentType.ProcessGroup), filter(([response, currentPg]) => response.component.id !== currentPg), switchMap(([response]) => of( @@ -2156,7 +2155,7 @@ export class FlowEffects { this.flowService.stopRemoteProcessGroupsInProcessGroup(request) ]).pipe( map(([stopPgResponse]) => { - return FlowActions.stopComponentSuccess({ + return FlowActions.stopProcessGroupSuccess({ response: { type: request.type, component: stopPgResponse @@ -2178,7 +2177,7 @@ export class FlowEffects { */ stopCurrentProcessGroupSuccess$ = createEffect(() => this.actions$.pipe( - ofType(FlowActions.stopComponentSuccess), + ofType(FlowActions.stopProcessGroupSuccess), map((action) => action.response), concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)), filter(([response, currentPg]) => response.component.id === currentPg), @@ -2191,10 +2190,9 @@ export class FlowEffects { */ stopProcessGroupSuccess$ = createEffect(() => this.actions$.pipe( - ofType(FlowActions.stopComponentSuccess), + ofType(FlowActions.stopProcessGroupSuccess), map((action) => action.response), concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)), - filter(([response]) => response.type === ComponentType.ProcessGroup), filter(([response, currentPg]) => response.component.id !== currentPg), switchMap(([response]) => of( diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.reducer.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.reducer.ts index 01db056062..1b5a54d707 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.reducer.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.reducer.ts @@ -30,6 +30,7 @@ import { flowApiError, groupComponents, groupComponentsSuccess, + loadChildProcessGroupSuccess, loadConnectionSuccess, loadInputPortSuccess, loadProcessGroup, @@ -37,7 +38,6 @@ import { loadProcessorSuccess, loadRemoteProcessGroupSuccess, navigateWithoutTransform, - loadChildProcessGroupSuccess, resetFlowState, runOnce, runOnceSuccess, @@ -333,6 +333,7 @@ export const flowReducer = createReducer( draftState.saving = false; }); }), + on(runOnceSuccess, (state, { response }) => { return produce(state, (draftState) => { const collection: any[] | null = getComponentCollection(draftState, ComponentType.Processor); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts index 8ea5f224ee..c19437aa9c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts @@ -510,6 +510,22 @@ export interface StartComponentResponse { component: ComponentEntity; } +export interface StartProcessGroupResponse { + type: ComponentType; + component: { + id: string; + state: string; + }; +} + +export interface StopProcessGroupResponse { + type: ComponentType; + component: { + id: string; + state: string; + }; +} + export interface StartComponentsResponse { components: StartComponentsResponse[]; }