@@ -14,7 +14,7 @@ import { map, startWith, switchMap } from 'rxjs/operators';
1414import { VersionHistoryDataService } from '../../../core/data/version-history-data.service' ;
1515import { AlertType } from '../../../shared/alert/alert-type' ;
1616import { getItemPageRoute } from '../../item-page-routing-paths' ;
17- import { Router } from '@angular/router' ;
17+ import { ActivatedRoute , Router } from '@angular/router' ;
1818
1919@Component ( {
2020 selector : 'ds-item-versions-notice' ,
@@ -67,7 +67,8 @@ export class ItemVersionsNoticeComponent implements OnInit {
6767 destinationUrl$ : Observable < string > ;
6868
6969 constructor ( private versionHistoryService : VersionHistoryDataService ,
70- private router : Router ) {
70+ private router : Router ,
71+ private activatedRoute : ActivatedRoute ) {
7172 }
7273
7374 /**
@@ -97,12 +98,14 @@ export class ItemVersionsNoticeComponent implements OnInit {
9798 }
9899 // Compute the destination URL from latestVersion$ with the namespace
99100 this . destinationUrl$ = this . latestVersion$ . pipe (
100- switchMap ( latestVersion => latestVersion ?. item || of ( null ) ) , // Handle the nested observable
101+ switchMap ( latestVersion => latestVersion ?. item || of ( null ) ) ,
101102 map ( item => {
102- const payload = item ?. payload ;
103- if ( ! payload ) { return '' ; } // Fallback if no payload
104- const routeCommands = [ this . getItemPage ( payload ) ] ; // Generate route commands
105- return this . router . createUrlTree ( routeCommands ) . toString ( ) ; // Convert to full URL
103+ const routeCommands = [ this . getItemPage ( item ?. payload ) ] ; // e.g., ['/items/xyz']
104+
105+ // Use the current ActivatedRoute to make it work like [routerLink]
106+ const urlTree = this . router . createUrlTree ( routeCommands , { relativeTo : this . activatedRoute } ) ;
107+
108+ return this . router . serializeUrl ( urlTree ) ; // Get the final URL string
106109 } )
107110 ) ;
108111 }
0 commit comments