mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
ensure parameter node id is a folder instance (#166)
This commit is contained in:
committed by
Denys Vuika
parent
92c147fae3
commit
9428913900
@@ -77,7 +77,7 @@ describe('FilesComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
node = { id: 'node-id' };
|
||||
node = { id: 'node-id', isFolder: true };
|
||||
page = {
|
||||
list: {
|
||||
entries: ['a', 'b', 'c'],
|
||||
@@ -134,6 +134,17 @@ describe('FilesComponent', () => {
|
||||
|
||||
expect(component.onFetchError).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('if should navigate to parent if node is not a folder', () => {
|
||||
node.isFolder = false;
|
||||
node.parentId = 'parent-id';
|
||||
spyOn(component, 'fetchNode').and.returnValue(Observable.of(node));
|
||||
spyOn(router, 'navigate');
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith([ '/personal-files', 'parent-id' ]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('refresh on events', () => {
|
||||
|
@@ -76,7 +76,13 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
this.isLoading = true;
|
||||
|
||||
this.fetchNode(nodeId)
|
||||
.do((node) => this.updateCurrentNode(node))
|
||||
.do((node) => {
|
||||
if (node.isFolder) {
|
||||
this.updateCurrentNode(node);
|
||||
} else {
|
||||
this.router.navigate(['/personal-files', node.parentId]);
|
||||
}
|
||||
})
|
||||
.flatMap((node) => this.fetchNodes(node.id))
|
||||
.subscribe(
|
||||
(page) => {
|
||||
|
Reference in New Issue
Block a user