Revert snackbar changes (#2778)

* Revert "[AAE-10766] upgrade to new About component (#2769)"

This reverts commit 5ce4835e4c.

* restore about dialog changes

* latest ADF alpha
This commit is contained in:
Denys Vuika
2022-11-15 17:01:04 +00:00
committed by GitHub
parent 854fb28374
commit cc41a575ac
11 changed files with 134 additions and 303 deletions

View File

@@ -53,9 +53,9 @@ import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { Store } from '@ngrx/store';
import { ContentManagementService } from './content-management.service';
import { NodeActionsService } from './node-actions.service';
import { TranslationService, AlfrescoApiService, FileModel, NotificationService } from '@alfresco/adf-core';
import { TranslationService, AlfrescoApiService, FileModel } from '@alfresco/adf-core';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
import { NodeEntry, Node, VersionPaging } from '@alfresco/js-api';
import { NewVersionUploaderDataAction, NewVersionUploaderService, NodeAspectService, ViewVersion } from '@alfresco/adf-content-services';
@@ -65,7 +65,7 @@ describe('ContentManagementService', () => {
let contentApi: ContentApiService;
let store: Store<AppStore>;
let contentManagementService: ContentManagementService;
let notificationService: NotificationService;
let snackBar: MatSnackBar;
let nodeActions: NodeActionsService;
let translationService: TranslationService;
let alfrescoApiService: AlfrescoApiService;
@@ -82,7 +82,7 @@ describe('ContentManagementService', () => {
actions$ = TestBed.inject(Actions);
store = TestBed.inject(Store);
contentManagementService = TestBed.inject(ContentManagementService);
notificationService = TestBed.inject(NotificationService);
snackBar = TestBed.inject(MatSnackBar);
nodeActions = TestBed.inject(NodeActionsService);
translationService = TestBed.inject(TranslationService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
@@ -98,7 +98,7 @@ describe('ContentManagementService', () => {
beforeEach(() => {
subject = new Subject<string>();
spyOn(notificationService, 'openSnackMessageAction').and.callThrough();
spyOn(snackBar, 'open').and.callThrough();
});
afterEach(() => subject.complete());
@@ -114,7 +114,7 @@ describe('ContentManagementService', () => {
subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
});
it('notifies successful copy of multiple nodes', () => {
@@ -128,7 +128,7 @@ describe('ContentManagementService', () => {
subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL');
});
it('notifies partially copy of one node out of a multiple selection of nodes', () => {
@@ -142,7 +142,7 @@ describe('ContentManagementService', () => {
subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR');
});
it('notifies partially copy of more nodes out of a multiple selection of nodes', () => {
@@ -160,7 +160,7 @@ describe('ContentManagementService', () => {
subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL');
});
it('notifies of failed copy of multiple nodes', () => {
@@ -178,7 +178,7 @@ describe('ContentManagementService', () => {
subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_PLURAL');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_PLURAL');
});
it('notifies of failed copy of one node', () => {
@@ -192,7 +192,7 @@ describe('ContentManagementService', () => {
subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_SINGULAR');
});
it('notifies error if success message was not emitted', () => {
@@ -205,7 +205,7 @@ describe('ContentManagementService', () => {
subject.next('');
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
});
it('notifies permission error on copy of node', () => {
@@ -216,7 +216,7 @@ describe('ContentManagementService', () => {
subject.error(new Error(JSON.stringify({ error: { statusCode: 403 } })));
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.PERMISSION');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.PERMISSION');
});
it('notifies generic error message on all errors, but 403', () => {
@@ -228,7 +228,7 @@ describe('ContentManagementService', () => {
subject.error(new Error(JSON.stringify({ error: { statusCode: 404 } })));
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
});
});
@@ -239,7 +239,7 @@ describe('ContentManagementService', () => {
subject = new Subject<string>();
spyOn(nodeActions, 'copyNodes').and.returnValue(subject);
spyOn(notificationService, 'openSnackMessageAction').and.returnValue({
spyOn(snackBar, 'open').and.returnValue({
onAction: () => of(null)
} as MatSnackBarRef<SimpleSnackBar>);
});
@@ -255,7 +255,7 @@ describe('ContentManagementService', () => {
nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
expect(contentApi.deleteNode).toHaveBeenCalledWith(createdItems[0].entry.id, { permanent: true });
});
@@ -292,7 +292,7 @@ describe('ContentManagementService', () => {
nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL');
expect(spyOnDeleteNode).toHaveBeenCalled();
expect(spyOnDeleteNode.calls.allArgs()).toEqual([
@@ -313,7 +313,7 @@ describe('ContentManagementService', () => {
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(contentApi.deleteNode).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
});
it('notifies when some error of type Error occurs on Undo action', () => {
@@ -328,7 +328,7 @@ describe('ContentManagementService', () => {
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(contentApi.deleteNode).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
});
it('notifies permission error when it occurs on Undo action', () => {
@@ -343,7 +343,7 @@ describe('ContentManagementService', () => {
expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(contentApi.deleteNode).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
});
});
@@ -366,7 +366,7 @@ describe('ContentManagementService', () => {
beforeEach(() => {
subject = new Subject<string>();
spyOn(notificationService, 'openSnackMessageAction').and.callThrough();
spyOn(snackBar, 'open').and.callThrough();
});
afterEach(() => subject.complete());
@@ -388,7 +388,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
});
it('notifies successful move of multiple nodes', () => {
@@ -409,7 +409,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PLURAL');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PLURAL');
});
it('notifies partial move of a node', () => {
@@ -428,7 +428,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR');
});
it('notifies partial move of multiple nodes', () => {
@@ -447,7 +447,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.PLURAL');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.PLURAL');
});
it('notifies successful move and the number of nodes that could not be moved', () => {
@@ -466,9 +466,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe(
'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.FAIL'
);
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.FAIL');
});
it('notifies successful move and the number of partially moved ones', () => {
@@ -487,9 +485,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe(
'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR'
);
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR');
});
it('notifies error if success message was not emitted', () => {
@@ -507,7 +503,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
});
it('notifies permission error on move of node', () => {
@@ -518,7 +514,7 @@ describe('ContentManagementService', () => {
nodeActions.moveNodes(null).error(new Error(JSON.stringify({ error: { statusCode: 403 } })));
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.PERMISSION');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.PERMISSION');
});
it('notifies generic error message on all errors, but 403', () => {
@@ -529,7 +525,7 @@ describe('ContentManagementService', () => {
nodeActions.moveNodes(null).error(new Error(JSON.stringify({ error: { statusCode: 404 } })));
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
});
it('notifies conflict error message on 409', () => {
@@ -540,7 +536,7 @@ describe('ContentManagementService', () => {
nodeActions.moveNodes(null).error(new Error(JSON.stringify({ error: { statusCode: 409 } })));
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.NODE_MOVE');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.NODE_MOVE');
});
it('notifies error if move response has only failed items', () => {
@@ -559,7 +555,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC');
});
});
@@ -584,7 +580,7 @@ describe('ContentManagementService', () => {
subject = new Subject<string>();
spyOn(nodeActions, 'moveNodes').and.returnValue(subject);
spyOn(notificationService, 'openSnackMessageAction').and.returnValue({
spyOn(snackBar, 'open').and.returnValue({
onAction: () => of(null)
} as MatSnackBarRef<SimpleSnackBar>);
});
@@ -610,7 +606,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(movedItems);
expect(nodeActions.moveNodeAction).toHaveBeenCalledWith(movedItems.succeeded[0].itemMoved.entry, movedItems.succeeded[0].initialParentId);
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
});
it('should move node back to initial parent, after succeeded move of a single file', () => {
@@ -638,7 +634,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(movedItems);
expect(nodeActions.moveNodeAction).toHaveBeenCalledWith(node.entry, initialParent);
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
});
it('should restore deleted folder back to initial parent, after succeeded moving all its files', () => {
@@ -670,7 +666,7 @@ describe('ContentManagementService', () => {
nodeActions.contentMoved.next(movedItems);
expect(contentApi.restoreNode).toHaveBeenCalled();
expect(notificationService.openSnackMessageAction['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR');
});
it('should notify when error occurs on Undo Move action', fakeAsync((done) => {

View File

@@ -56,7 +56,7 @@ import {
NewVersionUploaderData,
NewVersionUploaderDataAction
} from '@alfresco/adf-content-services';
import { TranslationService, AlfrescoApiService, NotificationService } from '@alfresco/adf-core';
import { TranslationService, AlfrescoApiService } from '@alfresco/adf-core';
import {
DeletedNodesPaging,
MinimalNodeEntity,
@@ -69,6 +69,7 @@ import {
} from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Store } from '@ngrx/store';
import { forkJoin, Observable, of, zip } from 'rxjs';
import { catchError, map, mergeMap, take, tap } from 'rxjs/operators';
@@ -93,7 +94,7 @@ export class ContentManagementService {
private dialogRef: MatDialog,
private nodeActionsService: NodeActionsService,
private translation: TranslationService,
private notificationService: NotificationService,
private snackBar: MatSnackBar,
private nodeAspectService: NodeAspectService,
private appHookService: AppHookService,
private newVersionUploaderService: NewVersionUploaderService,
@@ -532,9 +533,10 @@ export class ContentManagementService {
failed: failedItems
});
this.notificationService
.openSnackMessageAction(message, undo, {
panelClass: 'info-snackbar'
this.snackBar
.open(message, undo, {
panelClass: 'info-snackbar',
duration: 3000
})
.onAction()
.subscribe(() => this.undoCopyNodes(newItems));
@@ -668,6 +670,7 @@ export class ContentManagementService {
const message = this.getDeleteMessage(status);
if (message && status.someSucceeded) {
message.duration = 10000;
message.userAction = new SnackbarUserAction('APP.ACTIONS.UNDO', new UndoDeleteNodesAction([...status.success]));
}
@@ -1066,12 +1069,13 @@ export class ContentManagementService {
});
// TODO: review in terms of i18n
this.notificationService
.openSnackMessageAction(
this.snackBar
.open(
messages[successMessage] + beforePartialSuccessMessage + messages[partialSuccessMessage] + beforeFailedMessage + messages[failedMessage],
undo,
{
panelClass: 'info-snackbar'
panelClass: 'info-snackbar',
duration: 3000
}
)
.onAction()