Skip to content

Commit ef5c94c

Browse files
committed
NIFI-14191: Add the Reference Process Group to the URL when navigating to the Parent
1 parent 87f1487 commit ef5c94c

6 files changed

Lines changed: 53 additions & 5 deletions

File tree

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/flow/flow.actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ export const setSkipTransform = createAction(
553553
props<{ skipTransform: boolean }>()
554554
);
555555

556+
export const setLeavingProcessGroupId = createAction(
557+
`${CANVAS_PREFIX} Set Leaving Process Group Id`,
558+
props<{ leavingProcessGroupId: string | null }>()
559+
);
560+
556561
/**
557562
* allowTransition is a flag that can be set that indicates if a transition should be used when applying a transform.
558563
* By default, restoring the viewport or selecting/centering components will not use a transition unless explicitly

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,9 +2823,18 @@ export class FlowEffects {
28232823
() =>
28242824
this.actions$.pipe(
28252825
ofType(FlowActions.leaveProcessGroup),
2826-
concatLatestFrom(() => this.store.select(selectParentProcessGroupId)),
2827-
filter(([, parentProcessGroupId]) => parentProcessGroupId != null),
2828-
tap(([, parentProcessGroupId]) => {
2826+
concatLatestFrom(() => [
2827+
this.store.select(selectParentProcessGroupId),
2828+
this.store.select(selectCurrentProcessGroupId)
2829+
]),
2830+
filter(
2831+
([, parentProcessGroupId, currentProcessGroupId]) =>
2832+
parentProcessGroupId != null && currentProcessGroupId != null
2833+
),
2834+
tap(([, parentProcessGroupId, currentProcessGroupId]) => {
2835+
this.store.dispatch(
2836+
FlowActions.setLeavingProcessGroupId({ leavingProcessGroupId: currentProcessGroupId })
2837+
);
28292838
this.router.navigate(['/process-groups', parentProcessGroupId]);
28302839
})
28312840
),

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/flow/flow.reducer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
setAllowTransition,
6565
setDragging,
6666
setFlowAnalysisOpen,
67+
setLeavingProcessGroupId,
6768
setNavigationCollapsed,
6869
setOperationCollapsed,
6970
setRegistryClients,
@@ -172,6 +173,7 @@ export const initialState: FlowState = {
172173
versionSaving: false,
173174
transitionRequired: false,
174175
skipTransform: false,
176+
leavingProcessGroupId: null,
175177
allowTransition: false,
176178
navigationCollapsed: false,
177179
operationCollapsed: false,
@@ -558,6 +560,10 @@ export const flowReducer = createReducer(
558560
...state,
559561
skipTransform: true
560562
})),
563+
on(setLeavingProcessGroupId, (state, { leavingProcessGroupId }) => ({
564+
...state,
565+
leavingProcessGroupId
566+
})),
561567
on(setNavigationCollapsed, (state, { navigationCollapsed }) => ({
562568
...state,
563569
navigationCollapsed

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/flow/flow.selectors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ export const selectDragging = createSelector(selectFlowState, (state: FlowState)
166166

167167
export const selectSkipTransform = createSelector(selectFlowState, (state: FlowState) => state.skipTransform);
168168

169+
export const selectLeavingProcessGroupId = createSelector(
170+
selectFlowState,
171+
(state: FlowState) => state.leavingProcessGroupId
172+
);
173+
169174
export const selectAllowTransition = createSelector(selectFlowState, (state: FlowState) => state.allowTransition);
170175

171176
export const selectFunnels = createSelector(

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/state/flow/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ export interface FlowState {
661661
dragging: boolean;
662662
transitionRequired: boolean;
663663
skipTransform: boolean;
664+
leavingProcessGroupId: string | null;
664665
allowTransition: boolean;
665666
saving: boolean;
666667
navigationCollapsed: boolean;

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/canvas/canvas.component.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import {
2525
editComponent,
2626
editCurrentProcessGroup,
2727
loadProcessGroup,
28+
navigateWithoutTransform,
2829
paste,
2930
resetFlowState,
3031
selectComponents,
32+
setLeavingProcessGroupId,
3133
setSkipTransform,
3234
startProcessGroupPolling,
3335
stopProcessGroupPolling
@@ -49,6 +51,7 @@ import {
4951
selectFunnel,
5052
selectInputPort,
5153
selectLabel,
54+
selectLeavingProcessGroupId,
5255
selectOutputPort,
5356
selectProcessGroup,
5457
selectProcessGroupIdFromRoute,
@@ -142,15 +145,34 @@ export class Canvas implements OnInit, OnDestroy {
142145
distinctUntilChanged(),
143146
switchMap(() => this.store.select(selectProcessGroupRoute)),
144147
filter((processGroupRoute) => processGroupRoute != null),
145-
concatLatestFrom(() => this.store.select(selectSkipTransform)),
148+
concatLatestFrom(() => [
149+
this.store.select(selectSkipTransform),
150+
this.store.select(selectCurrentProcessGroupId),
151+
this.store.select(selectLeavingProcessGroupId)
152+
]),
146153
takeUntilDestroyed()
147154
)
148-
.subscribe(([, skipTransform]) => {
155+
.subscribe(([, skipTransform, currentProcessGroupId, leavingProcessGroupId]) => {
149156
if (skipTransform) {
150157
this.store.dispatch(setSkipTransform({ skipTransform: false }));
151158
} else {
152159
this.store.dispatch(restoreViewport());
153160
}
161+
162+
// If leaving process group, select it after parent PG has loaded
163+
if (leavingProcessGroupId && currentProcessGroupId != leavingProcessGroupId) {
164+
this.store.dispatch(setLeavingProcessGroupId({ leavingProcessGroupId: null }));
165+
this.store.dispatch(
166+
navigateWithoutTransform({
167+
url: [
168+
'/process-groups',
169+
currentProcessGroupId,
170+
ComponentType.ProcessGroup,
171+
leavingProcessGroupId
172+
]
173+
})
174+
);
175+
}
154176
});
155177

156178
// handle single component selection

0 commit comments

Comments
 (0)