[ACS-6891] The user is not redirected to the library page after deleting the library from the Manage Members view (#3673)

This commit is contained in:
DominikIwanek
2024-02-29 09:41:32 +01:00
committed by GitHub
parent ec5c5cf25d
commit 224cd62cbb
2 changed files with 42 additions and 26 deletions

View File

@@ -22,28 +22,29 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, fakeAsync, tick, flush } from '@angular/core/testing';
import { of, throwError, Subject, BehaviorSubject, EMPTY } from 'rxjs';
import { Actions, ofType, EffectsModule } from '@ngrx/effects';
import { fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
import { BehaviorSubject, EMPTY, of, Subject, throwError } from 'rxjs';
import { Actions, EffectsModule, ofType } from '@ngrx/effects';
import {
AppStore,
SnackbarWarningAction,
SnackbarInfoAction,
SnackbarErrorAction,
PurgeDeletedNodesAction,
RestoreDeletedNodesAction,
NavigateToParentFolder,
CopyNodesAction,
DeleteNodesAction,
MoveNodesAction,
CopyNodesAction,
ShareNodeAction,
SetSelectedNodesAction,
UnlockWriteAction,
SnackbarActionTypes,
NavigateRouteAction,
NavigateToParentFolder,
NodeActionTypes,
PurgeDeletedNodesAction,
ReloadDocumentListAction,
ViewNodeVersionAction,
ViewNodeExtras
RestoreDeletedNodesAction,
SetSelectedNodesAction,
ShareNodeAction,
SnackbarActionTypes,
SnackbarErrorAction,
SnackbarInfoAction,
SnackbarWarningAction,
UnlockWriteAction,
ViewNodeExtras,
ViewNodeVersionAction
} from '@alfresco/aca-shared/store';
import { map } from 'rxjs/operators';
import { NodeEffects } from '../store/effects/node.effects';
@@ -52,17 +53,17 @@ 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, NotificationService } from '@alfresco/adf-core';
import { NotificationService, TranslationService } from '@alfresco/adf-core';
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBarModule, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
import { NodeEntry, Node, VersionPaging } from '@alfresco/js-api';
import { Node, NodeEntry, VersionPaging } from '@alfresco/js-api';
import {
FileModel,
NewVersionUploaderDataAction,
NewVersionUploaderService,
NodeAspectService,
ViewVersion,
NodesApiService,
FileModel
ViewVersion
} from '@alfresco/adf-content-services';
describe('ContentManagementService', () => {
@@ -1769,4 +1770,18 @@ describe('ContentManagementService', () => {
expect(document.querySelector).not.toHaveBeenCalled();
});
});
describe('deleteLibrary', () => {
it('should dispatch NavigateRouteAction to /libraries after successful deletion', fakeAsync(() => {
const libraryId = 'test-library-id';
spyOn(contentApi, 'deleteSite').and.returnValue(of(null));
spyOn(store, 'dispatch').and.callThrough();
contentManagementService.deleteLibrary(libraryId);
tick();
expect(store.dispatch).toHaveBeenCalledWith(new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED'));
expect(store.dispatch).toHaveBeenCalledWith(new NavigateRouteAction(['/libraries']));
}));
});
});

View File

@@ -48,15 +48,15 @@ import {
ConfirmDialogComponent,
FolderDialogComponent,
LibraryDialogComponent,
ShareDialogComponent,
NodeAspectService,
NewVersionUploaderService,
NewVersionUploaderDialogData,
NewVersionUploaderData,
NewVersionUploaderDataAction,
NodesApiService
NewVersionUploaderDialogData,
NewVersionUploaderService,
NodeAspectService,
NodesApiService,
ShareDialogComponent
} from '@alfresco/adf-content-services';
import { TranslationService, NotificationService } from '@alfresco/adf-core';
import { NotificationService, TranslationService } from '@alfresco/adf-core';
import { DeletedNodesPaging, Node, NodeEntry, PathInfo, SiteBodyCreate, SiteEntry } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
@@ -289,6 +289,7 @@ export class ContentManagementService {
() => {
this.appHookService.libraryDeleted.next(id);
this.store.dispatch(new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED'));
this.store.dispatch(new NavigateRouteAction(['/libraries']));
},
() => {
this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.DELETE_LIBRARY_FAILED'));