Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIFI-13104] Unknown Route handling #8725

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { authenticationGuard } from './service/guard/authentication.guard';
import { RouteNotFound } from './pages/route-not-found/feature/route-not-found.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -101,6 +102,12 @@ const routes: Routes = [
canMatch: [authenticationGuard],
loadChildren: () =>
import('./pages/flow-designer/feature/flow-designer.module').then((m) => m.FlowDesignerModule)
},
{
path: '**',
component: RouteNotFound,
loadChildren: () =>
import('./pages/route-not-found/feature/route-not-found.module').then((m) => m.RouteNotFoundModule)
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { OverridePolicyDialog } from '../../ui/common/override-policy-dialog/ove
import { MEDIUM_DIALOG, SMALL_DIALOG } from '../../../../index';
import { HttpErrorResponse } from '@angular/common/http';
import { loadCurrentUser } from '../../../../state/current-user/current-user.actions';
import { ErrorHelper } from '../../../../service/error-helper.service';

@Injectable()
export class AccessPolicyEffects {
Expand All @@ -45,7 +46,8 @@ export class AccessPolicyEffects {
private store: Store<NiFiState>,
private router: Router,
private accessPoliciesService: AccessPolicyService,
private dialog: MatDialog
private dialog: MatDialog,
private errorHelper: ErrorHelper
) {}

setAccessPolicy$ = createEffect(() =>
Expand Down Expand Up @@ -128,7 +130,7 @@ export class AccessPolicyEffects {
return of(
AccessPolicyActions.accessPolicyApiBannerError({
response: {
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
}
})
);
Expand Down Expand Up @@ -163,7 +165,7 @@ export class AccessPolicyEffects {
of(
AccessPolicyActions.accessPolicyApiBannerError({
response: {
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
}
})
)
Expand Down Expand Up @@ -240,7 +242,7 @@ export class AccessPolicyEffects {
of(
AccessPolicyActions.accessPolicyApiBannerError({
response: {
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
}
})
)
Expand Down Expand Up @@ -347,7 +349,7 @@ export class AccessPolicyEffects {
of(
AccessPolicyActions.accessPolicyApiBannerError({
response: {
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
}
})
)
Expand Down Expand Up @@ -420,7 +422,7 @@ export class AccessPolicyEffects {
of(
AccessPolicyActions.accessPolicyApiBannerError({
response: {
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
}
})
)
Expand Down Expand Up @@ -477,7 +479,7 @@ export class AccessPolicyEffects {
of(
AccessPolicyActions.accessPolicyApiBannerError({
response: {
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
}
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import * as ErrorActions from '../../../../state/error/error.actions';
import { catchError, from, map, of, switchMap } from 'rxjs';
import { AccessPolicyService } from '../../service/access-policy.service';
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHelper } from '../../../../service/error-helper.service';

@Injectable()
export class PolicyComponentEffects {
constructor(
private actions$: Actions,
private accessPoliciesService: AccessPolicyService
private accessPoliciesService: AccessPolicyService,
private errorHelper: ErrorHelper
) {}

loadPolicyComponent$ = createEffect(() =>
Expand Down Expand Up @@ -63,7 +65,7 @@ export class PolicyComponentEffects {
} else {
return of(
ErrorActions.snackBarError({
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import * as ErrorActions from '../../../../state/error/error.actions';
import { catchError, combineLatest, map, of, switchMap } from 'rxjs';
import { AccessPolicyService } from '../../service/access-policy.service';
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHelper } from '../../../../service/error-helper.service';

@Injectable()
export class TenantsEffects {
constructor(
private actions$: Actions,
private accessPoliciesService: AccessPolicyService
private accessPoliciesService: AccessPolicyService,
private errorHelper: ErrorHelper
) {}

loadTenants$ = createEffect(() =>
Expand All @@ -46,7 +48,7 @@ export class TenantsEffects {
catchError((errorResponse: HttpErrorResponse) =>
of(
ErrorActions.snackBarError({
error: errorResponse.error
error: this.errorHelper.getErrorString(errorResponse)
})
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { createAction, props } from '@ngrx/store';
import { ClusterListingEntity, ClusterNode, ClusterNodeEntity, SelectClusterNodeRequest } from './index';
import { HttpErrorResponse } from '@angular/common/http';

const CLUSTER_LISTING_PREFIX = '[Cluster Listing]';

Expand Down Expand Up @@ -70,7 +71,7 @@ export const removeNodeSuccess = createAction(

export const clusterNodeSnackbarError = createAction(
`${CLUSTER_LISTING_PREFIX} Cluster Node Snackbar Error`,
props<{ error: string }>()
props<{ errorResponse: HttpErrorResponse }>()
);

export const selectClusterNode = createAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class ClusterListingEffects {
return ClusterListingActions.updateNodeSuccess({ response: entity });
}),
catchError((errorResponse: HttpErrorResponse) => {
return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error }));
return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse }));
})
)
)
Expand Down Expand Up @@ -149,7 +149,7 @@ export class ClusterListingEffects {
return ClusterListingActions.updateNodeSuccess({ response: entity });
}),
catchError((errorResponse: HttpErrorResponse) => {
return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error }));
return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse }));
})
)
)
Expand Down Expand Up @@ -188,7 +188,7 @@ export class ClusterListingEffects {
return ClusterListingActions.updateNodeSuccess({ response: entity });
}),
catchError((errorResponse: HttpErrorResponse) => {
return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error }));
return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse }));
})
)
)
Expand Down Expand Up @@ -227,7 +227,7 @@ export class ClusterListingEffects {
return ClusterListingActions.removeNodeSuccess({ response: request });
}),
catchError((errorResponse: HttpErrorResponse) => {
return of(ClusterListingActions.clusterNodeSnackbarError({ error: errorResponse.error }));
return of(ClusterListingActions.clusterNodeSnackbarError({ errorResponse }));
})
)
)
Expand Down Expand Up @@ -319,8 +319,10 @@ export class ClusterListingEffects {
clusterNodeSnackbarError$ = createEffect(() =>
this.actions$.pipe(
ofType(ClusterListingActions.clusterNodeSnackbarError),
map((action) => action.error),
switchMap((errorResponse) => of(ErrorActions.snackBarError({ error: errorResponse })))
map((action) => action.errorResponse),
switchMap((errorResponse) =>
of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }))
)
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { createAction, props } from '@ngrx/store';
import { LoadCounterListingResponse, ResetCounterRequest, ResetCounterSuccess } from './index';
import { HttpErrorResponse } from '@angular/common/http';

const COUNTER_PREFIX = '[Counter Listing]';

Expand All @@ -29,7 +30,7 @@ export const loadCountersSuccess = createAction(

export const counterListingApiError = createAction(
`${COUNTER_PREFIX} Load Counter Listing Error`,
props<{ error: string }>()
props<{ errorResponse: HttpErrorResponse }>()
);

export const promptCounterReset = createAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class CounterListingEffects {
})
),
catchError((errorResponse: HttpErrorResponse) =>
of(CounterListingActions.counterListingApiError({ error: errorResponse.error }))
of(CounterListingActions.counterListingApiError({ errorResponse }))
)
)
)
Expand All @@ -111,8 +111,10 @@ export class CounterListingEffects {
counterListingApiError$ = createEffect(() =>
this.actions$.pipe(
ofType(CounterListingActions.counterListingApiError),
map((action) => action.error),
switchMap((error) => of(ErrorActions.snackBarError({ error })))
map((action) => action.errorResponse),
switchMap((errorResponse) =>
of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }))
)
)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export class FlowConfigurationHistoryListingEffects {
this.actions$.pipe(
ofType(HistoryActions.flowConfigurationHistorySnackbarError),
map((action) => action.errorResponse),
switchMap((errorResponse) => of(ErrorActions.snackBarError({ error: errorResponse.error })))
switchMap((errorResponse) =>
of(ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) }))
)
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const routes: Routes = [
}
]
},
{ path: '', component: RootGroupRedirector, canActivate: [rootGroupGuard] }
{ path: '', component: RootGroupRedirector, canActivate: [rootGroupGuard], pathMatch: 'full' }
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import * as ParameterActions from '../state/parameter/parameter.actions';
import { FlowService } from './flow.service';
import { MEDIUM_DIALOG } from '../../../index';
import { ClusterConnectionService } from '../../../service/cluster-connection.service';
import { ErrorHelper } from '../../../service/error-helper.service';

@Injectable({
providedIn: 'root'
Expand All @@ -43,7 +44,8 @@ export class ParameterHelperService {
private flowService: FlowService,
private parameterService: ParameterService,
private clusterConnectionService: ClusterConnectionService,
private client: Client
private client: Client,
private errorHelper: ErrorHelper
) {}

/**
Expand All @@ -56,7 +58,9 @@ export class ParameterHelperService {
return this.flowService.getParameterContext(parameterContextId).pipe(
take(1),
catchError((errorResponse: HttpErrorResponse) => {
this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error }));
this.store.dispatch(
ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })
);

// consider the error handled and allow the user to reattempt the action
return EMPTY;
Expand All @@ -82,7 +86,9 @@ export class ParameterHelperService {
return (name: string, sensitive: boolean, value: string | null) => {
return this.parameterService.getParameterContext(parameterContextId, false).pipe(
catchError((errorResponse: HttpErrorResponse) => {
this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error }));
this.store.dispatch(
ErrorActions.snackBarError({ error: this.errorHelper.getErrorString(errorResponse) })
);

// consider the error handled and allow the user to reattempt the action
return EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ControllerServiceService } from '../controller-service.service';
import { HttpErrorResponse } from '@angular/common/http';
import { fullScreenError } from '../../../../state/error/error.actions';
import { ClusterConnectionService } from '../../../../service/cluster-connection.service';
import { ErrorHelper } from '../../../../service/error-helper.service';

export const controllerServiceAdvancedUiParamsResolver: ResolveFn<AdvancedUiParams> = (
route: ActivatedRouteSnapshot
Expand All @@ -35,6 +36,7 @@ export const controllerServiceAdvancedUiParamsResolver: ResolveFn<AdvancedUiPara
const controllerServiceService: ControllerServiceService = inject(ControllerServiceService);
const client: Client = inject(Client);
const clusterConnectionService: ClusterConnectionService = inject(ClusterConnectionService);
const errorHelper: ErrorHelper = inject(ErrorHelper);

// getting id parameter from activated route because ngrx router store
// is not initialized when this resolver executes
Expand All @@ -54,7 +56,7 @@ export const controllerServiceAdvancedUiParamsResolver: ResolveFn<AdvancedUiPara
fullScreenError({
errorDetail: {
title: 'Unable to Open Advanced UI',
message: errorResponse.error
message: errorHelper.getErrorString(errorResponse)
}
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import { Client } from '../../../../service/client.service';
import { fullScreenError } from '../../../../state/error/error.actions';
import { HttpErrorResponse } from '@angular/common/http';
import { ClusterConnectionService } from '../../../../service/cluster-connection.service';
import { ErrorHelper } from '../../../../service/error-helper.service';

export const processorAdvancedUiParamsResolver: ResolveFn<AdvancedUiParams> = (route: ActivatedRouteSnapshot) => {
const store: Store<NiFiState> = inject(Store);
const flowService: FlowService = inject(FlowService);
const client: Client = inject(Client);
const clusterConnectionService: ClusterConnectionService = inject(ClusterConnectionService);
const errorHelper: ErrorHelper = inject(ErrorHelper);

// getting id parameter from activated route because ngrx router store
// is not initialized when this resolver executes
Expand All @@ -52,7 +54,7 @@ export const processorAdvancedUiParamsResolver: ResolveFn<AdvancedUiParams> = (r
fullScreenError({
errorDetail: {
title: 'Unable to Open Advanced UI',
message: errorResponse.error
message: errorHelper.getErrorString(errorResponse)
}
})
);
Expand Down
Loading