[ACA-2047] navigate to restored library content folder (#836)

This commit is contained in:
Cilibiu Bogdan
2018-11-28 09:49:39 +00:00
committed by Denys Vuika
parent 6e0bfe8187
commit 9b717c2743
2 changed files with 63 additions and 2 deletions
@@ -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({}));
+23 -2
View File
@@ -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(