Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-8604][Legal Hold] [My Libraries] ADW - No warning when deleting Legal Hold #4069

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions projects/aca-content/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@
"MOBILE_APP_BUTTON_LABEL": "Open in App",
"DOWNLOAD_APP_BUTTON_LABEL": "Don't have the app? Download now.",
"OPEN_ALFRESCO_MOBILE_APP": "Open using Alfresco Mobile application?"
},
"CONFIRM_DELETE_HOLDS": {
"TITLE": "Delete holds?",
"MESSAGE_SINGULAR": "You have selected {{ name }} hold to be removed. All the items it's holding will be released.",
"MESSAGE_PLURAL": "You have selected {{ count }} holds to be removed. All the items they are holding will be released."
}
},
"DOCUMENT_LIST": {
Expand Down
57 changes: 44 additions & 13 deletions projects/aca-content/src/lib/services/content-management.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {
NodesApiService,
ShareDialogComponent
} from '@alfresco/adf-content-services';
import { NotificationService, TranslationService, ConfirmDialogComponent } from '@alfresco/adf-core';
import { ConfirmDialogComponent, DialogComponent, DialogSize, NotificationService, TranslationService } from '@alfresco/adf-core';
import { DeletedNodesPaging, Node, NodeEntry, PathInfo, SiteBodyCreate, SiteEntry } from '@alfresco/js-api';
import { inject, Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
Expand Down Expand Up @@ -657,29 +657,60 @@ export class ContentManagementService {

deleteNodes(items: NodeEntry[]): void {
const batch: Observable<DeletedNodeInfo>[] = [];
const areHolds = items.some((node) => node.entry.nodeType === 'rma:hold');
const action = areHolds ? this.showWarningOnHoldDeleteAction(items) : of(true);

items.forEach((node) => {
batch.push(this.deleteNode(node));
});
action.pipe(take(1)).subscribe((removeApproval) => {
if (removeApproval) {
items.forEach((node) => {
batch.push(this.deleteNode(node));
});

forkJoin(...batch).subscribe((data: DeletedNodeInfo[]) => {
const status = this.processStatus(data);
const message = this.getDeleteMessage(status);
forkJoin(...batch).subscribe((data: DeletedNodeInfo[]) => {
const status = this.processStatus(data);
const message = this.getDeleteMessage(status);

if (message && status.someSucceeded) {
message.userAction = new SnackbarUserAction('APP.ACTIONS.UNDO', new UndoDeleteNodesAction([...status.success]));
}
if (message && status.someSucceeded) {
message.userAction = new SnackbarUserAction('APP.ACTIONS.UNDO', new UndoDeleteNodesAction([...status.success]));
}

this.store.dispatch(message);
this.store.dispatch(message);

if (status.someSucceeded) {
this.appHookService.nodesDeleted.next();
if (status.someSucceeded) {
this.appHookService.nodesDeleted.next();
this.documentListService.reload();
}
});
} else {
this.documentListService.reload();
}
this.store.dispatch(new ShowLoaderAction(false));
});
}

showWarningOnHoldDeleteAction(nodes: NodeEntry[]): Observable<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're leaking the enterprise code to community edition.. ACA should know nothing about legal hold, this should only be a part of governance

const message =
nodes.length === 1
? this.translation.instant('APP.DIALOGS.CONFIRM_DELETE_HOLDS.MESSAGE_SINGULAR', {
name: nodes[0].entry.name
})
: this.translation.instant('APP.DIALOGS.CONFIRM_DELETE_HOLDS.MESSAGE_PLURAL', {
count: nodes.length
});

const dialogRef = this.dialogRef.open(DialogComponent, {
data: {
title: 'APP.DIALOGS.CONFIRM_DELETE_HOLDS.TITLE',
description: message,
dialogSize: DialogSize.Alert,
confirmButtonTitle: 'APP.ACTIONS.DELETE',
isConfirmButtonDisabled$: of(false)
}
});

return dialogRef.afterClosed();
}

undoDeleteNodes(items: DeletedNodeInfo[]): void {
const batch: Observable<DeletedNodeInfo>[] = [];

Expand Down
Loading