mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-8604] Add new param to control undo for deleting nodes (#4308)
* [ACS-8604] Add new param to control undo for deleting nodes * [ACS-8604] Unit test fixes
This commit is contained in:
@@ -660,7 +660,7 @@ export class ContentManagementService {
|
||||
);
|
||||
}
|
||||
|
||||
deleteNodes(items: NodeEntry[]): void {
|
||||
deleteNodes(items: NodeEntry[], allowUndo = true): void {
|
||||
const batch: Observable<DeletedNodeInfo>[] = [];
|
||||
|
||||
items.forEach((node) => {
|
||||
@@ -671,7 +671,7 @@ export class ContentManagementService {
|
||||
const status = this.processStatus(data);
|
||||
const message = this.getDeleteMessage(status);
|
||||
|
||||
if (message && status.someSucceeded) {
|
||||
if (message && status.someSucceeded && allowUndo) {
|
||||
message.userAction = new SnackbarUserAction('APP.ACTIONS.UNDO', new UndoDeleteNodesAction([...status.success]));
|
||||
}
|
||||
|
||||
|
@@ -218,9 +218,9 @@ describe('NodeEffects', () => {
|
||||
const node: any = {};
|
||||
store.dispatch(new DeleteNodesAction([node]));
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new DeleteNodesAction([node]));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new DeleteNodesAction([node], true));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new ShowLoaderAction(true));
|
||||
expect(contentService.deleteNodes).toHaveBeenCalledWith([node]);
|
||||
expect(contentService.deleteNodes).toHaveBeenCalledWith([node], true);
|
||||
});
|
||||
|
||||
it('should delete nodes from the active selection', fakeAsync(() => {
|
||||
@@ -233,9 +233,9 @@ describe('NodeEffects', () => {
|
||||
|
||||
store.dispatch(new DeleteNodesAction(null));
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new DeleteNodesAction(null));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new DeleteNodesAction(null, true));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new ShowLoaderAction(true));
|
||||
expect(contentService.deleteNodes).toHaveBeenCalledWith([node]);
|
||||
expect(contentService.deleteNodes).toHaveBeenCalledWith([node], true);
|
||||
}));
|
||||
|
||||
it('should do nothing if invoking delete with no data', () => {
|
||||
|
@@ -163,14 +163,14 @@ export class NodeEffects {
|
||||
map((action) => {
|
||||
this.store.dispatch(new ShowLoaderAction(true));
|
||||
if (action?.payload?.length > 0) {
|
||||
this.contentService.deleteNodes(action.payload);
|
||||
this.contentService.deleteNodes(action.payload, action.allowUndo);
|
||||
} else {
|
||||
this.store
|
||||
.select(getAppSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe((selection) => {
|
||||
if (selection && selection.count > 0) {
|
||||
this.contentService.deleteNodes(selection.nodes);
|
||||
this.contentService.deleteNodes(selection.nodes, action.allowUndo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user