This is an automated email from the ASF dual-hosted git repository.

rfellows pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 67b387e5c7 NIFI-13102: (#8704)
67b387e5c7 is described below

commit 67b387e5c7a5e5bef82bcacd26c2be9ffc34f0c5
Author: Matt Gilman <matt.c.gil...@gmail.com>
AuthorDate: Tue Apr 30 13:02:50 2024 -0400

    NIFI-13102: (#8704)
    
    - Updating API error handling for Convert to Parameter and Empty Queue.
    
    This closes #8704
---
 .../state/parameter/parameter.effects.ts           | 56 +++++++++-------------
 .../app/pages/flow-designer/state/queue/index.ts   |  3 +-
 .../flow-designer/state/queue/queue.effects.ts     | 22 +++++----
 .../flow-designer/state/queue/queue.reducer.ts     |  8 ----
 .../property-table/property-table.component.ts     |  2 +-
 5 files changed, 37 insertions(+), 54 deletions(-)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts
index e59ad344a9..9413370b2f 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/parameter/parameter.effects.ts
@@ -21,8 +21,8 @@ import { concatLatestFrom } from '@ngrx/operators';
 import * as ParameterActions from './parameter.actions';
 import { Store } from '@ngrx/store';
 import { CanvasState } from '../index';
-import { asyncScheduler, catchError, from, interval, map, NEVER, of, 
switchMap, takeUntil } from 'rxjs';
-import { ParameterContextUpdateRequest } from '../../../../state/shared';
+import { asyncScheduler, catchError, filter, from, interval, map, of, 
switchMap, takeUntil } from 'rxjs';
+import { isDefinedAndNotNull, ParameterContextUpdateRequest } from 
'../../../../state/shared';
 import { selectUpdateRequest } from './parameter.selectors';
 import { ParameterService } from '../../service/parameter.service';
 import { HttpErrorResponse } from '@angular/common/http';
@@ -86,29 +86,25 @@ export class ParameterEffects {
     pollParameterContextUpdateRequest$ = createEffect(() =>
         this.actions$.pipe(
             ofType(ParameterActions.pollParameterContextUpdateRequest),
-            concatLatestFrom(() => this.store.select(selectUpdateRequest)),
-            switchMap(([, updateRequest]) => {
-                if (updateRequest) {
-                    return 
from(this.parameterService.pollParameterContextUpdate(updateRequest.request)).pipe(
-                        map((response) =>
-                            
ParameterActions.pollParameterContextUpdateRequestSuccess({
-                                response: {
-                                    requestEntity: response
-                                }
+            concatLatestFrom(() => 
this.store.select(selectUpdateRequest).pipe(isDefinedAndNotNull())),
+            switchMap(([, updateRequest]) =>
+                
from(this.parameterService.pollParameterContextUpdate(updateRequest.request)).pipe(
+                    map((response) =>
+                        
ParameterActions.pollParameterContextUpdateRequestSuccess({
+                            response: {
+                                requestEntity: response
+                            }
+                        })
+                    ),
+                    catchError((errorResponse: HttpErrorResponse) =>
+                        of(
+                            ParameterActions.parameterApiError({
+                                error: errorResponse.error
                             })
-                        ),
-                        catchError((error) =>
-                            of(
-                                ParameterActions.parameterApiError({
-                                    error: error.error
-                                })
-                            )
                         )
-                    );
-                } else {
-                    return NEVER;
-                }
-            })
+                    )
+                )
+            )
         )
     );
 
@@ -116,14 +112,8 @@ export class ParameterEffects {
         this.actions$.pipe(
             ofType(ParameterActions.pollParameterContextUpdateRequestSuccess),
             map((action) => action.response),
-            switchMap((response) => {
-                const updateRequest: ParameterContextUpdateRequest = 
response.requestEntity.request;
-                if (updateRequest.complete) {
-                    return 
of(ParameterActions.stopPollingParameterContextUpdateRequest());
-                } else {
-                    return NEVER;
-                }
-            })
+            filter((response) => response.requestEntity.request.complete),
+            switchMap(() => 
of(ParameterActions.stopPollingParameterContextUpdateRequest()))
         )
     );
 
@@ -142,10 +132,10 @@ export class ParameterEffects {
                 if (updateRequest) {
                     return 
from(this.parameterService.deleteParameterContextUpdate(updateRequest.request)).pipe(
                         map(() => 
ParameterActions.editParameterContextComplete()),
-                        catchError((error) =>
+                        catchError((errorResponse: HttpErrorResponse) =>
                             of(
                                 ParameterActions.parameterApiError({
-                                    error: error.error
+                                    error: errorResponse.error
                                 })
                             )
                         )
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/index.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/index.ts
index 6177c01031..45f44a256a 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/index.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/index.ts
@@ -60,6 +60,5 @@ export interface QueueState {
     connectionId: string | null;
     processGroupId: string | null;
     loadedTimestamp: string;
-    error: string | null;
-    status: 'pending' | 'loading' | 'error' | 'success';
+    status: 'pending' | 'loading' | 'success';
 }
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts
index 858c3276a7..b4cd6b947b 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.effects.ts
@@ -19,6 +19,7 @@ import { Injectable } from '@angular/core';
 import { Actions, createEffect, ofType } from '@ngrx/effects';
 import { concatLatestFrom } from '@ngrx/operators';
 import * as QueueActions from './queue.actions';
+import * as ErrorActions from '../../../../state/error/error.actions';
 import { Store } from '@ngrx/store';
 import { asyncScheduler, catchError, filter, from, interval, map, of, 
switchMap, take, takeUntil, tap } from 'rxjs';
 import { selectDropConnectionId, selectDropProcessGroupId, 
selectDropRequestEntity } from './queue.selectors';
@@ -26,7 +27,6 @@ import { QueueService } from '../../service/queue.service';
 import { DropRequest } from './index';
 import { CancelDialog } from 
'../../../../ui/common/cancel-dialog/cancel-dialog.component';
 import { MatDialog } from '@angular/material/dialog';
-import { NiFiCommon } from '../../../../service/nifi-common.service';
 import { isDefinedAndNotNull } from '../../../../state/shared';
 import { YesNoDialog } from 
'../../../../ui/common/yes-no-dialog/yes-no-dialog.component';
 import { OkDialog } from '../../../../ui/common/ok-dialog/ok-dialog.component';
@@ -40,8 +40,7 @@ export class QueueEffects {
         private actions$: Actions,
         private store: Store<CanvasState>,
         private queueService: QueueService,
-        private dialog: MatDialog,
-        private nifiCommon: NiFiCommon
+        private dialog: MatDialog
     ) {}
 
     promptEmptyQueueRequest$ = createEffect(
@@ -330,12 +329,15 @@ export class QueueEffects {
         { dispatch: false }
     );
 
-    queueApiError$ = createEffect(
-        () =>
-            this.actions$.pipe(
-                ofType(QueueActions.queueApiError),
-                tap(() => this.dialog.closeAll())
-            ),
-        { dispatch: false }
+    queueApiError$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(QueueActions.queueApiError),
+            map((action) => action.error),
+            tap(() => {
+                this.dialog.closeAll();
+                
this.store.dispatch(QueueActions.stopPollingEmptyQueueRequest());
+            }),
+            switchMap((error) => of(ErrorActions.snackBarError({ error })))
+        )
     );
 }
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.reducer.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.reducer.ts
index b752e37243..c88d0a2a97 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.reducer.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/queue/queue.reducer.ts
@@ -22,7 +22,6 @@ import {
     submitEmptyQueueRequest,
     submitEmptyQueueRequestSuccess,
     resetQueueState,
-    queueApiError,
     submitEmptyQueuesRequest
 } from './queue.actions';
 
@@ -31,7 +30,6 @@ export const initialState: QueueState = {
     processGroupId: null,
     connectionId: null,
     loadedTimestamp: 'N/A',
-    error: null,
     status: 'pending'
 };
 
@@ -51,14 +49,8 @@ export const queueReducer = createReducer(
         ...state,
         dropEntity: response.dropEntity,
         loadedTimestamp: response.dropEntity.dropRequest.lastUpdated,
-        error: null,
         status: 'success' as const
     })),
-    on(queueApiError, (state, { error }) => ({
-        ...state,
-        error,
-        status: 'error' as const
-    })),
     on(resetQueueState, () => ({
         ...initialState
     }))
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/property-table/property-table.component.ts
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/property-table/property-table.component.ts
index 81c9a32a75..a2e1da4c9f 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/property-table/property-table.component.ts
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/property-table/property-table.component.ts
@@ -482,7 +482,7 @@ export class PropertyTable implements AfterViewInit, 
ControlValueAccessor {
     }
 
     convertToParameterClicked(item: PropertyItem): void {
-        this.convertToParameter(item.property, item.descriptor.sensitive, 
item.value)
+        this.convertToParameter(item.descriptor.displayName, 
item.descriptor.sensitive, item.value)
             .pipe(take(1))
             .subscribe((propertyValue) => {
                 item.value = propertyValue;

Reply via email to