diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts index 1d6a9940ac..82b2c856e6 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/error-helper.service.ts @@ -25,7 +25,7 @@ import { NiFiCommon } from './nifi-common.service'; export class ErrorHelper { constructor(private nifiCommon: NiFiCommon) {} - fullScreenError(errorResponse: HttpErrorResponse): Action { + fullScreenError(errorResponse: HttpErrorResponse, skipReplaceUrl?: boolean): Action { let title: string; let message: string; @@ -56,6 +56,7 @@ export class ErrorHelper { } return ErrorActions.fullScreenError({ + skipReplaceUrl, errorDetail: { title, message diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/authorization.guard.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/authorization.guard.ts index 3de1b625e5..ab8a1e8fa5 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/authorization.guard.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/authorization.guard.ts @@ -21,6 +21,7 @@ import { map } from 'rxjs'; import { Store } from '@ngrx/store'; import { CurrentUser, CurrentUserState } from '../../state/current-user'; import { selectCurrentUser } from '../../state/current-user/current-user.selectors'; +import { fullScreenError } from '../../state/error/error.actions'; export const authorizationGuard = ( authorizationCheck: (user: CurrentUser) => boolean, @@ -36,8 +37,20 @@ export const authorizationGuard = ( return true; } - // TODO - replace with 403 error page - return router.parseUrl(fallbackUrl || '/'); + if (fallbackUrl) { + return router.parseUrl(fallbackUrl); + } + + store.dispatch( + fullScreenError({ + skipReplaceUrl: true, + errorDetail: { + title: 'Unable to load', + message: 'Authorization check failed. Contact the system administrator.' + } + }) + ); + return false; }) ); }; diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/flow-configuration.guard.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/flow-configuration.guard.ts index 70439c0daa..8bd3afde19 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/flow-configuration.guard.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/guard/flow-configuration.guard.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { CanMatchFn, Router } from '@angular/router'; +import { CanMatchFn } from '@angular/router'; import { inject } from '@angular/core'; import { catchError, map, of, switchMap, tap } from 'rxjs'; import { Store } from '@ngrx/store'; @@ -23,14 +23,17 @@ import { FlowConfiguration, FlowConfigurationState } from '../../state/flow-conf import { selectFlowConfiguration } from '../../state/flow-configuration/flow-configuration.selectors'; import { FlowConfigurationService } from '../flow-configuration.service'; import { loadFlowConfigurationSuccess } from '../../state/flow-configuration/flow-configuration.actions'; +import { fullScreenError } from '../../state/error/error.actions'; +import { HttpErrorResponse } from '@angular/common/http'; +import { ErrorHelper } from '../error-helper.service'; export const checkFlowConfiguration = ( flowConfigurationCheck: (flowConfiguration: FlowConfiguration) => boolean ): CanMatchFn => { return () => { - const router: Router = inject(Router); const store: Store = inject(Store); const flowConfigurationService: FlowConfigurationService = inject(FlowConfigurationService); + const errorHelper: ErrorHelper = inject(ErrorHelper); return store.select(selectFlowConfiguration).pipe( switchMap((flowConfiguration) => { @@ -53,12 +56,20 @@ export const checkFlowConfiguration = ( return true; } - // TODO - replace with error page - return router.parseUrl('/'); + store.dispatch( + fullScreenError({ + skipReplaceUrl: true, + errorDetail: { + title: 'Unable to load', + message: 'Flow configuration check failed' + } + }) + ); + return false; }), - catchError(() => { - // TODO - replace with error page - return of(router.parseUrl('/')); + catchError((errorResponse: HttpErrorResponse) => { + store.dispatch(errorHelper.fullScreenError(errorResponse, true)); + return of(false); }) ); }; diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.actions.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.actions.ts index 6278eb92fc..da4ff5a42c 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.actions.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.actions.ts @@ -18,7 +18,10 @@ import { createAction, props } from '@ngrx/store'; import { ErrorDetail } from './index'; -export const fullScreenError = createAction('[Error] Full Screen Error', props<{ errorDetail: ErrorDetail }>()); +export const fullScreenError = createAction( + '[Error] Full Screen Error', + props<{ errorDetail: ErrorDetail; skipReplaceUrl?: boolean }>() +); export const snackBarError = createAction('[Error] Snackbar Error', props<{ error: string }>()); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.effects.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.effects.ts index 7344927e85..96ed053135 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.effects.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.effects.ts @@ -36,9 +36,15 @@ export class ErrorEffects { () => this.actions$.pipe( ofType(ErrorActions.fullScreenError), - tap(() => { + map((action) => action.skipReplaceUrl), + tap((skipReplaceUrl) => { this.dialog.openDialogs.forEach((dialog) => dialog.close('ROUTED')); - this.router.navigate(['/error'], { replaceUrl: true }); + + if (skipReplaceUrl) { + this.router.navigate(['/error']); + } else { + this.router.navigate(['/error'], { replaceUrl: true }); + } }) ), { dispatch: false }