mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACA-1426] Search - back from preview breaks view (#376)
* build url from string * fix tests
This commit is contained in:
parent
f2cc8e260b
commit
f21ddee491
@ -205,7 +205,7 @@ describe('PreviewComponent', () => {
|
||||
component.onVisibilityChanged(false);
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(
|
||||
['libraries']
|
||||
['libraries', {}]
|
||||
);
|
||||
});
|
||||
|
||||
@ -219,7 +219,7 @@ describe('PreviewComponent', () => {
|
||||
component.onVisibilityChanged(false);
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(
|
||||
['libraries', 'site1']
|
||||
['libraries', {}, 'site1']
|
||||
);
|
||||
});
|
||||
|
||||
@ -233,7 +233,7 @@ describe('PreviewComponent', () => {
|
||||
component.onVisibilityChanged(false);
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(
|
||||
['shared']
|
||||
['shared', {}]
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router, UrlTree, UrlSegmentGroup, UrlSegment, PRIMARY_OUTLET } from '@angular/router';
|
||||
import { AlfrescoApiService, UserPreferencesService, ObjectUtils } from '@alfresco/adf-core';
|
||||
import { Node, MinimalNodeEntity } from 'alfresco-js-api';
|
||||
import { NodePermissionService } from '../../common/services/node-permission.service';
|
||||
@ -124,7 +124,7 @@ export class PreviewComponent implements OnInit {
|
||||
const shouldSkipNavigation = this.routesSkipNavigation.includes(this.previewLocation);
|
||||
|
||||
if (!isVisible) {
|
||||
const route = [this.previewLocation];
|
||||
const route = this.getNavigationCommands(this.previewLocation);
|
||||
|
||||
if ( !shouldSkipNavigation && this.folderId ) {
|
||||
route.push(this.folderId);
|
||||
@ -333,4 +333,20 @@ export class PreviewComponent implements OnInit {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
private getNavigationCommands(url: string): any[] {
|
||||
const urlTree: UrlTree = this.router.parseUrl(url);
|
||||
const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET];
|
||||
|
||||
if (!urlSegmentGroup) {
|
||||
return [url];
|
||||
}
|
||||
|
||||
const urlSegments: UrlSegment[] = urlSegmentGroup.segments;
|
||||
|
||||
return urlSegments.reduce(function(acc, item) {
|
||||
acc.push(item.path, item.parameters);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user