diff --git a/src/app/services/content-management.service.spec.ts b/src/app/services/content-management.service.spec.ts index f33894ed55..51f52bb3ff 100644 --- a/src/app/services/content-management.service.spec.ts +++ b/src/app/services/content-management.service.spec.ts @@ -36,6 +36,7 @@ import { SNACKBAR_WARNING, PurgeDeletedNodesAction, RestoreDeletedNodesAction, + NavigateToParentFolder, NavigateRouteAction, NAVIGATE_ROUTE, DeleteNodesAction, @@ -1205,6 +1206,45 @@ describe('ContentManagementService', () => { expect(contentApi.restoreNode).toHaveBeenCalled(); })); + it('should navigate to library folder when node is a library content', fakeAsync(() => { + spyOn(store, 'dispatch').and.callThrough(); + spyOn(contentApi, 'restoreNode').and.returnValue(of({})); + spyOn(contentApi, 'getDeletedNodes').and.returnValue( + of({ + list: { entries: [] } + }) + ); + + const path = { + elements: [ + { + id: '1-1', + name: 'Company Home' + }, + { + id: '1-2', + name: 'Sites' + } + ] + }; + + const selection = [ + { + entry: { + id: '1', + path + } + } + ]; + + store.dispatch(new RestoreDeletedNodesAction(selection)); + + expect( + store.dispatch['calls'].argsFor(1)[0].userAction.action instanceof + NavigateToParentFolder + ).toBe(true); + })); + describe('refresh()', () => { it('dispatch event on finish', fakeAsync(done => { spyOn(contentApi, 'restoreNode').and.returnValue(of({})); diff --git a/src/app/services/content-management.service.ts b/src/app/services/content-management.service.ts index 49e624fc41..5474e73218 100644 --- a/src/app/services/content-management.service.ts +++ b/src/app/services/content-management.service.ts @@ -37,6 +37,7 @@ import { SnackbarAction, SnackbarWarningAction, NavigateRouteAction, + NavigateToParentFolder, SnackbarUserAction, UndoDeleteNodesAction, SetSelectedNodesAction @@ -874,9 +875,17 @@ export class ContentManagementService { const isSite = this.isSite(status.success[0].entry); const path: PathInfoEntity = status.success[0].entry.path; const parent = path.elements[path.elements.length - 1]; - const route = isSite ? ['/libraries'] : ['/personal-files', parent.id]; + const route = isSite + ? ['/libraries', parent.id] + : ['/personal-files', parent.id]; - const navigate = new NavigateRouteAction(route); + let navigate; + + if (this.isLibraryContent(path)) { + navigate = new NavigateToParentFolder(status.success[0]); + } else { + navigate = new NavigateRouteAction(route); + } message.userAction = new SnackbarUserAction( 'APP.ACTIONS.VIEW', @@ -892,6 +901,18 @@ export class ContentManagementService { return entry.nodeType === 'st:site'; } + private isLibraryContent(path: PathInfoEntity): boolean { + if ( + path && + path.elements.length >= 2 && + path.elements[1].name === 'Sites' + ) { + return true; + } + + return false; + } + private getRestoreMessage(status: DeleteStatus): SnackbarAction { if (status.someFailed && !status.oneFailed) { return new SnackbarErrorAction(