[ACA-3855] fix go home id you are in uuuid root (#1607)

* fix go home id you are in uuuid root

* fix lint
This commit is contained in:
Eugenio Romano 2020-08-14 16:57:49 +01:00 committed by GitHub
parent 8096741398
commit c015c8a6a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -265,6 +265,19 @@ describe('FilesComponent', () => {
expect(router.navigate).toHaveBeenCalledWith(['personal-files']);
});
it('should navigate home if node is root also if it contain a uuid', () => {
component.node = {
path: {
elements: [{ id: 'node-id' }]
}
} as any;
router.url = '/personal-files/895de2b3-1b69-4cc7-bff2-a0d7c86b7bc7';
component.navigate(node.id);
expect(router.navigate).toHaveBeenCalledWith(['personal-files']);
});
});
describe('isSiteContainer', () => {

View File

@ -132,7 +132,12 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
let urlToNavigate;
if (this.router.url.match(uuidRegEx)) {
urlToNavigate = this.router.url.replace(uuidRegEx, nodeId).split('/');
if (nodeId && !this.isRootNode(nodeId)) {
urlToNavigate = this.router.url.replace(uuidRegEx, nodeId).split('/');
} else {
urlToNavigate = this.router.url.replace(uuidRegEx, '').split('/');
urlToNavigate.pop();
}
urlToNavigate.shift();
} else {
urlToNavigate = this.router.url.split('/');