[ACA-1992] Keep favorite libraries navigation under same path (#1474)

* [ACA-1992] Keep favorite libraries navigation under same path

* Fix unit test
This commit is contained in:
davidcanonieto
2020-05-20 13:32:31 +01:00
committed by GitHub
parent 7ffecc546c
commit 51b461f859
5 changed files with 43 additions and 5 deletions

View File

@@ -47,7 +47,7 @@ export class CreateLibraryAction implements Action {
export class NavigateLibraryAction implements Action { export class NavigateLibraryAction implements Action {
readonly type = LibraryActionTypes.Navigate; readonly type = LibraryActionTypes.Navigate;
constructor(public payload?: string) {} constructor(public payload?: string, public route?: string) {}
} }
export class UpdateLibraryAction implements Action { export class UpdateLibraryAction implements Action {

View File

@@ -212,10 +212,15 @@ export const APP_ROUTES: Routes = [
] ]
}, },
{ {
path: 'favorite/libraries', path: 'favorite',
children: [ children: [
{ {
path: '', path: '',
pathMatch: 'full',
redirectTo: 'libraries'
},
{
path: 'libraries',
component: FavoriteLibrariesComponent, component: FavoriteLibrariesComponent,
data: { data: {
title: 'APP.BROWSE.LIBRARIES.MENU.FAVORITE_LIBRARIES.TITLE', title: 'APP.BROWSE.LIBRARIES.MENU.FAVORITE_LIBRARIES.TITLE',
@@ -224,6 +229,33 @@ export const APP_ROUTES: Routes = [
} }
] ]
}, },
{
path: 'favorite/libraries/:folderId',
children: [
{
path: '',
component: FilesComponent,
data: {
title: 'APP.BROWSE.LIBRARIES.MENU.FAVORITE_LIBRARIES.TITLE',
sortingPreferenceKey: 'libraries-files'
}
},
{
path: 'view/:nodeId',
outlet: 'viewer',
children: [
{
path: '',
data: {
navigateSource: 'libraries'
},
loadChildren:
'./components/viewer/viewer.module#AppViewerModule'
}
]
}
]
},
{ {
path: 'favorites', path: 'favorites',
data: { data: {

View File

@@ -144,7 +144,10 @@ describe('FavoriteLibrariesComponent', () => {
spyOn(router, 'navigate').and.stub(); spyOn(router, 'navigate').and.stub();
component.navigateTo({ entry: { guid: 'guid' } } as any); component.navigateTo({ entry: { guid: 'guid' } } as any);
expect(router.navigate).toHaveBeenCalledWith(['libraries', 'libraryId']); expect(router.navigate).toHaveBeenCalledWith([
'favorite/libraries',
'libraryId'
]);
}); });
}); });

View File

@@ -82,7 +82,9 @@ export class FavoriteLibrariesComponent extends PageComponent
navigateTo(node: SiteEntry) { navigateTo(node: SiteEntry) {
if (node && node.entry && node.entry.guid) { if (node && node.entry && node.entry.guid) {
this.store.dispatch(new NavigateLibraryAction(node.entry.guid)); this.store.dispatch(
new NavigateLibraryAction(node.entry.guid, 'favorite/libraries')
);
} }
} }

View File

@@ -107,7 +107,8 @@ export class LibraryEffects {
.pipe(map(node => node.entry.id)) .pipe(map(node => node.entry.id))
.subscribe( .subscribe(
id => { id => {
this.store.dispatch(new NavigateRouteAction(['libraries', id])); const route = action.route ? action.route : 'libraries';
this.store.dispatch(new NavigateRouteAction([route, id]));
}, },
() => { () => {
this.store.dispatch( this.store.dispatch(