NIFI-14191: Add the Reference Process Group to the URL when navigatin…#10816
NIFI-14191: Add the Reference Process Group to the URL when navigatin…#10816Freedom9339 wants to merge 2 commits intoapache:mainfrom
Conversation
291d2c6 to
ef5c94c
Compare
ef5c94c to
0dd1c73
Compare
|
Rebased. has anyone looked into this PR? |
I can give this a review today. |
mcgilman
left a comment
There was a problem hiding this comment.
Thanks for the PR @Freedom9339 and for taking the feedback from the previous PR into consideration.
The approach of navigating to just /process-groups/{parentId} (without the component in the URL) and using a store flag to trigger selection afterward avoids the regression that affected the previous PR -- search-based centering is preserved. That's a good improvement.
One concern I have is the same issue I flagged in the previous PR: the subscription chains in canvas.component.ts fire twice during cross-PG navigation -- once when the route changes (against stale store data) and again when the store finishes loading. I've confirmed this with runtime instrumentation: during a leave-PG operation, the viewport-restore subscriber fires first while selectCurrentProcessGroupId still holds the child PG ID (stale), and then fires again after the parent PG loads with the correct ID. This isn't something introduced by this PR -- it's a latent issue in the existing code. But this PR's leavingProcessGroupId guard implicitly relies on that double-fire to work correctly: the first stale firing is filtered out because currentProcessGroupId still equals leavingProcessGroupId, and only the second firing passes the guard. This means restoreViewport() is also dispatched twice per leave -- once against stale state and once against the correct state. Building on top of that double-fire makes it harder to address later.
I think it would be worth addressing the double-fire directly as part of this change. All three subscription chains in canvas.component.ts (viewport restore, single-component selection, and bulk selection) share the same pattern:
switchMap(() => this.store.select(selectCurrentProcessGroupId)),
distinctUntilChanged(),
switchMap(() => this.store.select(/* chain-specific selector */)),A sync guard can be inserted after distinctUntilChanged() to ensure the store and route agree before proceeding:
switchMap(() => this.store.select(selectCurrentProcessGroupId)),
distinctUntilChanged(),
concatLatestFrom(() => this.store.select(selectProcessGroupIdFromRoute)),
filter(([storeId, routeId]) => storeId === routeId),
switchMap(() => this.store.select(/* chain-specific selector */)),Both selectors already exist. This prevents any of the three chains from acting on stale data during cross-PG navigation and eliminates the redundant restoreViewport() dispatch.
With that in place, the child PG selection could be handled entirely in the leaveProcessGroup$ effect as a two-step navigation: first navigate to the parent PG (letting the viewport restore as usual), then listen for loadProcessGroupComplete and dispatch navigateWithoutTransform to select the child PG. This would avoid needing the new store state (leavingProcessGroupId, the action, the reducer case, and the selector) since the effect can capture the current PG ID at the time leaveProcessGroup is dispatched and use it after the load completes.
Happy to discuss further or help work through the details.
…ProcessGroupId from the store.
0dd1c73 to
1a74ede
Compare
|
Thank you for reviewing @mcgilman. I did try the method you mentioned, but it didn't work, the subscribe was still being fired twice. However, I was able to prevent the stale firing by wrapping the route filter inside a switchmap. I removed leavingProcessGroupId from the state and instead did what you suggested and handled everything from the leaveProcessGroup$ effect. I know you mentioned doing the same thing for single-component selection and bulk selection, but I wasn't able to recreate the double firing like how the viewport restore was. Is there a specific scenario where that is happening? |
…g to the Parent
Summary
NIFI-14191 - Added the Reference Process Group to the URL when navigating to the Parent. I took into consideration the issues brought up with the previous closed PR for this issue and made sure these changes only affect the behavior when leaving the process-group.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation