rfellows commented on code in PR #8859:
URL: https://github.com/apache/nifi/pull/8859#discussion_r1610398604
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/app.component.ts:
##########
@@ -33,16 +40,40 @@ export class AppComponent {
constructor(
private router: Router,
private storage: Storage,
- private themingService: ThemingService
+ private themingService: ThemingService,
+ private store: Store<NiFiState>
) {
- this.router.events.pipe(takeUntilDestroyed()).subscribe((event) => {
- if (event instanceof GuardsCheckStart) {
- this.guardLoading = true;
- }
- if (event instanceof GuardsCheckEnd || event instanceof
NavigationCancel) {
- this.guardLoading = false;
- }
- });
+ this.router.events
+ .pipe(
+ takeUntilDestroyed(),
+ tap((event) => {
+ if (event instanceof GuardsCheckStart) {
+ this.guardLoading = true;
+ }
+ if (event instanceof GuardsCheckEnd || event instanceof
NavigationCancel) {
+ this.guardLoading = false;
+ }
+ }),
+ filter((e) => e instanceof NavigationEnd),
+ map((e) => e as NavigationEnd),
+ concatLatestFrom(() => this.store.select(selectBackNavigation))
+ )
+ .subscribe(([event, previousBackNavigation]) => {
+ const extras = this.router.getCurrentNavigation()?.extras;
+ if (extras?.state?.['backNavigation']) {
+ const backNavigation: BackNavigation =
extras?.state?.['backNavigation'];
+ this.store.dispatch(
+ pushBackNavigation({
+ backNavigation
+ })
+ );
+ } else if (previousBackNavigation) {
+ if
(!event.url.startsWith(previousBackNavigation.routeBoundary.join('/'))) {
+ console.log('popping...');
+ this.store.dispatch(popBackNavigation());
+ }
Review Comment:
This logic doesn't consider the fact that there might be multiple
`backNavigation`'s in the store. If the user is more than one deep and
navigates to another page (link from referencing components, main menu, ...)
only the last 1 will be popped off and leaving the user with a potentially
confusing back navigation option.
Here is an example:

If i had navigated to the referencing process group for the parameter
context, the same thing would happen, but the back navigation would show over
the canvas which is odd.
<img width="1283" alt="Screenshot 2024-05-22 at 1 38 00 PM"
src="https://github.com/apache/nifi/assets/713866/3aca3ec2-0523-47f9-b2cc-54b20b067428">
_Also, the `console.log` should go away_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]