NIFI-13636: Fixing back navigation when navigating to manage access policies. (#9153)

This closes #9153
This commit is contained in:
Matt Gilman 2024-08-06 13:46:10 -04:00 committed by GitHub
parent 0ea55bebc8
commit 05c92e45d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 72 additions and 59 deletions

View File

@ -223,60 +223,75 @@ export class CanvasActionsService {
return this.canvasUtils.canManagePolicies(selection);
},
action: (selection: d3.Selection<any, any, any, any>, extraArgs?) => {
if (selection.empty()) {
if (extraArgs?.processGroupId) {
const routeBoundary: string[] = ['/access-policies'];
if (extraArgs?.processGroupId) {
if (selection.empty()) {
this.store.dispatch(
navigateToManageComponentPolicies({
request: {
resource: 'process-groups',
id: extraArgs.processGroupId,
backNavigationContext: 'Process Group'
backNavigation: {
route: ['/process-groups', extraArgs.processGroupId],
routeBoundary,
context: 'Process Group'
}
}
})
);
} else {
const selectionData = selection.datum();
const componentType: ComponentType = selectionData.type;
let resource = 'process-groups';
let context = 'Process Group';
switch (componentType) {
case ComponentType.Processor:
resource = 'processors';
context = 'Processor';
break;
case ComponentType.InputPort:
resource = 'input-ports';
context = 'Input Port';
break;
case ComponentType.OutputPort:
resource = 'output-ports';
context = 'Output Port';
break;
case ComponentType.Funnel:
resource = 'funnels';
context = 'Funnel';
break;
case ComponentType.Label:
resource = 'labels';
context = 'Label';
break;
case ComponentType.RemoteProcessGroup:
resource = 'remote-process-groups';
context = 'Remote Process Group';
break;
}
this.store.dispatch(
navigateToManageComponentPolicies({
request: {
resource,
id: selectionData.id,
backNavigation: {
route: [
'/process-groups',
extraArgs.processGroupId,
componentType,
selectionData.id
],
routeBoundary,
context
}
}
})
);
}
} else {
const selectionData = selection.datum();
const componentType: ComponentType = selectionData.type;
let resource = 'process-groups';
let backNavigationContext = 'Process Group';
switch (componentType) {
case ComponentType.Processor:
resource = 'processors';
backNavigationContext = 'Processor';
break;
case ComponentType.InputPort:
resource = 'input-ports';
backNavigationContext = 'Input Port';
break;
case ComponentType.OutputPort:
resource = 'output-ports';
backNavigationContext = 'Output Port';
break;
case ComponentType.Funnel:
resource = 'funnels';
backNavigationContext = 'Funnel';
break;
case ComponentType.Label:
resource = 'labels';
backNavigationContext = 'Label';
break;
case ComponentType.RemoteProcessGroup:
resource = 'remote-process-groups';
backNavigationContext = 'Remote Process Group';
break;
}
this.store.dispatch(
navigateToManageComponentPolicies({
request: {
resource,
id: selectionData.id,
backNavigationContext
}
})
);
}
}
},

View File

@ -1065,18 +1065,15 @@ export class FlowEffects {
this.actions$.pipe(
ofType(FlowActions.navigateToManageComponentPolicies),
map((action) => action.request),
concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)),
tap(([request, processGroupId]) => {
const routeBoundary: string[] = ['/access-policies'];
this.router.navigate([...routeBoundary, 'read', 'component', request.resource, request.id], {
state: {
backNavigation: {
route: ['/process-groups', processGroupId, request.resource, request.id],
routeBoundary,
context: request.backNavigationContext
} as BackNavigation
tap((request) => {
this.router.navigate(
[...request.backNavigation.routeBoundary, 'read', 'component', request.resource, request.id],
{
state: {
backNavigation: request.backNavigation
}
}
});
);
})
),
{ dispatch: false }

View File

@ -346,7 +346,7 @@ export interface OpenComponentDialogRequest {
export interface NavigateToManageComponentPoliciesRequest {
resource: string;
id: string;
backNavigationContext: string;
backNavigation: BackNavigation;
}
export interface EditComponentDialogRequest {

View File

@ -57,7 +57,7 @@ import {
selectSkipTransform,
selectViewStatusHistoryComponent
} from '../../state/flow/flow.selectors';
import { filter, map, switchMap, take } from 'rxjs';
import { filter, map, NEVER, switchMap, take } from 'rxjs';
import { restoreViewport } from '../../state/transform/transform.actions';
import { initialState } from '../../state/flow/flow.reducer';
import { CanvasContextMenu } from '../../service/canvas-context-menu.service';
@ -218,7 +218,8 @@ export class Canvas implements OnInit, OnDestroy {
component$ = this.store.select(selectLabel(selectedComponent.id));
break;
default:
throw 'Unrecognized Component Type';
component$ = NEVER;
break;
}
// combine the original selection with the component