mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
ACS-8572: Switch to using ADF document list reload (#4021)
This commit is contained in:
@@ -22,14 +22,14 @@
|
|||||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, ViewEncapsulation, OnInit, Input } from '@angular/core';
|
import { Component, ViewEncapsulation, OnInit, Input, inject } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { SelectionState } from '@alfresco/adf-extensions';
|
import { SelectionState } from '@alfresco/adf-extensions';
|
||||||
import { AppStore, ReloadDocumentListAction, getAppSelection } from '@alfresco/aca-shared/store';
|
import { AppStore, getAppSelection } from '@alfresco/aca-shared/store';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NodeFavoriteDirective } from '@alfresco/adf-content-services';
|
import { DocumentListService, NodeFavoriteDirective } from '@alfresco/adf-content-services';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
@@ -49,6 +49,8 @@ import { MatMenuModule } from '@angular/material/menu';
|
|||||||
host: { class: 'app-toggle-favorite' }
|
host: { class: 'app-toggle-favorite' }
|
||||||
})
|
})
|
||||||
export class ToggleFavoriteComponent implements OnInit {
|
export class ToggleFavoriteComponent implements OnInit {
|
||||||
|
private documentListService = inject(DocumentListService);
|
||||||
|
|
||||||
@Input() data: any;
|
@Input() data: any;
|
||||||
selection$: Observable<SelectionState>;
|
selection$: Observable<SelectionState>;
|
||||||
private reloadOnRoutes: string[] = [];
|
private reloadOnRoutes: string[] = [];
|
||||||
@@ -65,7 +67,7 @@ export class ToggleFavoriteComponent implements OnInit {
|
|||||||
|
|
||||||
onToggleEvent() {
|
onToggleEvent() {
|
||||||
if (this.reloadOnRoutes.includes(this.router.url)) {
|
if (this.reloadOnRoutes.includes(this.router.url)) {
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,9 +54,9 @@ describe('DocumentListDirective', () => {
|
|||||||
url: ''
|
url: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
const appHookServiceMock: any = {
|
const documentListServiceMock = {
|
||||||
reload: new Subject<any>(),
|
reload$: new Subject<any>(),
|
||||||
reset: new Subject<any>()
|
resetSelection$: new Subject<any>()
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockRoute: any = {
|
const mockRoute: any = {
|
||||||
@@ -80,7 +80,7 @@ describe('DocumentListDirective', () => {
|
|||||||
userPreferencesServiceMock,
|
userPreferencesServiceMock,
|
||||||
mockRoute,
|
mockRoute,
|
||||||
mockRouter,
|
mockRouter,
|
||||||
appHookServiceMock
|
documentListServiceMock as any
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -139,26 +139,17 @@ describe('DocumentListDirective', () => {
|
|||||||
expect(storeMock.dispatch).toHaveBeenCalled();
|
expect(storeMock.dispatch).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset and reload document list on `reload` event', () => {
|
|
||||||
documentListDirective.ngOnInit();
|
|
||||||
appHookServiceMock.reload.next();
|
|
||||||
|
|
||||||
expect(documentListMock.resetSelection).toHaveBeenCalled();
|
|
||||||
expect(documentListMock.reload).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reset store selection on `reload` event', () => {
|
it('should reset store selection on `reload` event', () => {
|
||||||
documentListDirective.ngOnInit();
|
documentListDirective.ngOnInit();
|
||||||
appHookServiceMock.reload.next();
|
documentListServiceMock.reload$.next();
|
||||||
|
|
||||||
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));
|
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset selection state on `reset` event', () => {
|
it('should reset selection state on `reset` event', () => {
|
||||||
documentListDirective.ngOnInit();
|
documentListDirective.ngOnInit();
|
||||||
appHookServiceMock.reset.next();
|
documentListServiceMock.resetSelection$.next();
|
||||||
|
|
||||||
expect(documentListMock.resetSelection).toHaveBeenCalled();
|
|
||||||
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));
|
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));
|
||||||
expect(documentListDirective.selectedNode).toBeNull();
|
expect(documentListDirective.selectedNode).toBeNull();
|
||||||
});
|
});
|
||||||
|
@@ -23,12 +23,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Directive, OnDestroy, OnInit, HostListener } from '@angular/core';
|
import { Directive, OnDestroy, OnInit, HostListener } from '@angular/core';
|
||||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
import { DocumentListComponent, DocumentListService } from '@alfresco/adf-content-services';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
|
||||||
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
||||||
import { takeUntil, filter } from 'rxjs/operators';
|
import { takeUntil, filter } from 'rxjs/operators';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
@@ -53,7 +52,7 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
|||||||
private preferences: UserPreferencesService,
|
private preferences: UserPreferencesService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private appHookService: AppHookService
|
private documentListService: DocumentListService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -92,11 +91,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
|||||||
)
|
)
|
||||||
.subscribe(() => this.onReady());
|
.subscribe(() => this.onReady());
|
||||||
|
|
||||||
this.appHookService.reload.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
this.documentListService.reload$.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||||
this.reload();
|
this.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.appHookService.reset.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
this.documentListService.resetSelection$.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||||
this.reset();
|
this.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -167,14 +166,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private reload() {
|
private reload() {
|
||||||
this.documentList.resetSelection();
|
|
||||||
this.store.dispatch(new SetSelectedNodesAction([]));
|
this.store.dispatch(new SetSelectedNodesAction([]));
|
||||||
this.documentList.reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private reset() {
|
private reset() {
|
||||||
this.selectedNode = null;
|
this.selectedNode = null;
|
||||||
this.documentList.resetSelection();
|
|
||||||
this.store.dispatch(new SetSelectedNodesAction([]));
|
this.store.dispatch(new SetSelectedNodesAction([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1582,7 +1582,7 @@ describe('ContentManagementService', () => {
|
|||||||
expect(spyOnDispatch).toHaveBeenCalledOnceWith(new RefreshPreviewAction(fakeNodeIsFile));
|
expect(spyOnDispatch).toHaveBeenCalledOnceWith(new RefreshPreviewAction(fakeNodeIsFile));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch ReloadDocumentListAction if dialog emit view action', () => {
|
it('should dispatch ViewNodeVersionAction if dialog emit view action', () => {
|
||||||
const fakeVersionId = '1';
|
const fakeVersionId = '1';
|
||||||
const fakeLocation: ViewNodeExtras = {
|
const fakeLocation: ViewNodeExtras = {
|
||||||
location: '/'
|
location: '/'
|
||||||
|
@@ -32,7 +32,6 @@ import {
|
|||||||
NavigateToParentFolder,
|
NavigateToParentFolder,
|
||||||
NodeInfo,
|
NodeInfo,
|
||||||
RefreshPreviewAction,
|
RefreshPreviewAction,
|
||||||
ReloadDocumentListAction,
|
|
||||||
SetSelectedNodesAction,
|
SetSelectedNodesAction,
|
||||||
ShowLoaderAction,
|
ShowLoaderAction,
|
||||||
SnackbarAction,
|
SnackbarAction,
|
||||||
@@ -45,6 +44,7 @@ import {
|
|||||||
ViewNodeVersionAction
|
ViewNodeVersionAction
|
||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
import {
|
import {
|
||||||
|
DocumentListService,
|
||||||
FolderDialogComponent,
|
FolderDialogComponent,
|
||||||
LibraryDialogComponent,
|
LibraryDialogComponent,
|
||||||
NewVersionUploaderData,
|
NewVersionUploaderData,
|
||||||
@@ -90,7 +90,8 @@ export class ContentManagementService {
|
|||||||
private appHookService: AppHookService,
|
private appHookService: AppHookService,
|
||||||
private newVersionUploaderService: NewVersionUploaderService,
|
private newVersionUploaderService: NewVersionUploaderService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private appSettingsService: AppSettingsService
|
private appSettingsService: AppSettingsService,
|
||||||
|
private documentListService: DocumentListService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
addFavorite(nodes: Array<NodeEntry>) {
|
addFavorite(nodes: Array<NodeEntry>) {
|
||||||
@@ -226,7 +227,7 @@ export class ContentManagementService {
|
|||||||
|
|
||||||
dialogInstance.afterClosed().subscribe((node) => {
|
dialogInstance.afterClosed().subscribe((node) => {
|
||||||
if (node) {
|
if (node) {
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
}
|
}
|
||||||
this.focusAfterClose(this.createMenuButtonSelector);
|
this.focusAfterClose(this.createMenuButtonSelector);
|
||||||
});
|
});
|
||||||
@@ -390,7 +391,7 @@ export class ContentManagementService {
|
|||||||
const failedStatus = this.processStatus([]);
|
const failedStatus = this.processStatus([]);
|
||||||
failedStatus.fail.push(...selection);
|
failedStatus.fail.push(...selection);
|
||||||
this.showRestoreNotification(failedStatus);
|
this.showRestoreNotification(failedStatus);
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +410,7 @@ export class ContentManagementService {
|
|||||||
|
|
||||||
if (!remainingNodes.length) {
|
if (!remainingNodes.length) {
|
||||||
this.showRestoreNotification(status);
|
this.showRestoreNotification(status);
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
} else {
|
} else {
|
||||||
this.restoreDeletedNodes(remainingNodes);
|
this.restoreDeletedNodes(remainingNodes);
|
||||||
}
|
}
|
||||||
@@ -436,7 +437,7 @@ export class ContentManagementService {
|
|||||||
const [operationResult, moveResponse] = result;
|
const [operationResult, moveResponse] = result;
|
||||||
this.showMoveMessage(nodes, operationResult, moveResponse);
|
this.showMoveMessage(nodes, operationResult, moveResponse);
|
||||||
|
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.showMoveMessage(nodes, error);
|
this.showMoveMessage(nodes, error);
|
||||||
@@ -542,7 +543,7 @@ export class ContentManagementService {
|
|||||||
forkJoin(...batch).subscribe(
|
forkJoin(...batch).subscribe(
|
||||||
() => {
|
() => {
|
||||||
this.appHookService.nodesDeleted.next(null);
|
this.appHookService.nodesDeleted.next(null);
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
let i18nMessageString = 'APP.MESSAGES.ERRORS.GENERIC';
|
let i18nMessageString = 'APP.MESSAGES.ERRORS.GENERIC';
|
||||||
@@ -632,7 +633,7 @@ export class ContentManagementService {
|
|||||||
)
|
)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => {
|
() => {
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
let message = 'APP.MESSAGES.ERRORS.GENERIC';
|
let message = 'APP.MESSAGES.ERRORS.GENERIC';
|
||||||
@@ -670,7 +671,7 @@ export class ContentManagementService {
|
|||||||
|
|
||||||
if (status.someSucceeded) {
|
if (status.someSucceeded) {
|
||||||
this.appHookService.nodesDeleted.next();
|
this.appHookService.nodesDeleted.next();
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
}
|
}
|
||||||
this.store.dispatch(new ShowLoaderAction(false));
|
this.store.dispatch(new ShowLoaderAction(false));
|
||||||
});
|
});
|
||||||
@@ -692,7 +693,7 @@ export class ContentManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (processedData.someSucceeded) {
|
if (processedData.someSucceeded) {
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -761,7 +762,7 @@ export class ContentManagementService {
|
|||||||
const status = this.processStatus(purgedNodes);
|
const status = this.processStatus(purgedNodes);
|
||||||
|
|
||||||
if (status.success.length) {
|
if (status.success.length) {
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendPurgeMessage(status);
|
this.sendPurgeMessage(status);
|
||||||
|
@@ -26,18 +26,18 @@ import { Actions, ofType, createEffect } from '@ngrx/effects';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { AppActionTypes, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store';
|
import { AppActionTypes, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppEffects {
|
export class AppEffects {
|
||||||
constructor(private actions$: Actions, private appHookService: AppHookService) {}
|
constructor(private actions$: Actions, private documentListService: DocumentListService) {}
|
||||||
|
|
||||||
reload = createEffect(
|
reload = createEffect(
|
||||||
() =>
|
() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType<ReloadDocumentListAction>(AppActionTypes.ReloadDocumentList),
|
ofType<ReloadDocumentListAction>(AppActionTypes.ReloadDocumentList),
|
||||||
map((action) => {
|
map(() => {
|
||||||
this.appHookService.reload.next(action);
|
this.documentListService.reload();
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
@@ -47,8 +47,8 @@ export class AppEffects {
|
|||||||
() =>
|
() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType<ResetSelectionAction>(AppActionTypes.ResetSelection),
|
ofType<ResetSelectionAction>(AppActionTypes.ResetSelection),
|
||||||
map((action) => {
|
map(() => {
|
||||||
this.appHookService.reset.next(action);
|
this.documentListService.resetSelection();
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
|
@@ -33,14 +33,14 @@ import { of, Subject } from 'rxjs';
|
|||||||
import { Node, NodeEntry } from '@alfresco/js-api';
|
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { CreateFromTemplateDialogComponent } from '../../dialogs/node-template/create-from-template.dialog';
|
import { CreateFromTemplateDialogComponent } from '../../dialogs/node-template/create-from-template.dialog';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
|
||||||
import { NotificationService } from '@alfresco/adf-core';
|
import { NotificationService } from '@alfresco/adf-core';
|
||||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
|
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
describe('TemplateEffects', () => {
|
describe('TemplateEffects', () => {
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
let nodeTemplateService: NodeTemplateService;
|
let nodeTemplateService: NodeTemplateService;
|
||||||
let appHookService: AppHookService;
|
let documentListService: DocumentListService;
|
||||||
let templateEffects: TemplateEffects;
|
let templateEffects: TemplateEffects;
|
||||||
let copyNodeSpy;
|
let copyNodeSpy;
|
||||||
let updateNodeSpy;
|
let updateNodeSpy;
|
||||||
@@ -91,7 +91,7 @@ describe('TemplateEffects', () => {
|
|||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
||||||
templateEffects = TestBed.inject(TemplateEffects);
|
templateEffects = TestBed.inject(TemplateEffects);
|
||||||
appHookService = TestBed.inject(AppHookService);
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
matDialog = TestBed.inject(MatDialog);
|
matDialog = TestBed.inject(MatDialog);
|
||||||
subject = new Subject<Node[]>();
|
subject = new Subject<Node[]>();
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ describe('TemplateEffects', () => {
|
|||||||
showErrorSpy = spyOn(notificationService, 'showError');
|
showErrorSpy = spyOn(notificationService, 'showError');
|
||||||
|
|
||||||
spyOn(store, 'dispatch').and.callThrough();
|
spyOn(store, 'dispatch').and.callThrough();
|
||||||
spyOn(appHookService.reload, 'next');
|
spyOn(documentListService, 'reload').and.stub();
|
||||||
spyOn(store, 'select').and.returnValue(of({ id: 'parent-id' }));
|
spyOn(store, 'select').and.returnValue(of({ id: 'parent-id' }));
|
||||||
spyOn(nodeTemplateService, 'selectTemplateDialog').and.returnValue(subject);
|
spyOn(nodeTemplateService, 'selectTemplateDialog').and.returnValue(subject);
|
||||||
|
|
||||||
@@ -212,6 +212,6 @@ describe('TemplateEffects', () => {
|
|||||||
const TEST_NODE = { id: 'test-node-id' } as Node;
|
const TEST_NODE = { id: 'test-node-id' } as Node;
|
||||||
store.dispatch(new CreateFromTemplateSuccess(TEST_NODE));
|
store.dispatch(new CreateFromTemplateSuccess(TEST_NODE));
|
||||||
tick();
|
tick();
|
||||||
expect(appHookService.reload.next).toHaveBeenCalledWith(TEST_NODE);
|
expect(documentListService.reload).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@@ -37,14 +37,15 @@ import {
|
|||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-template.service';
|
import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-template.service';
|
||||||
import { AlfrescoApiService, NotificationService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, NotificationService } from '@alfresco/adf-core';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
|
||||||
import { from, Observable, of } from 'rxjs';
|
import { from, Observable, of } from 'rxjs';
|
||||||
import { NodeEntry, NodeBodyUpdate, Node, NodesApi } from '@alfresco/js-api';
|
import { NodeEntry, NodeBodyUpdate, Node, NodesApi } from '@alfresco/js-api';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TemplateEffects {
|
export class TemplateEffects {
|
||||||
private notificationService = inject(NotificationService);
|
private notificationService = inject(NotificationService);
|
||||||
|
private documentListService = inject(DocumentListService);
|
||||||
|
|
||||||
private _nodesApi: NodesApi;
|
private _nodesApi: NodesApi;
|
||||||
get nodesApi(): NodesApi {
|
get nodesApi(): NodesApi {
|
||||||
@@ -54,7 +55,6 @@ export class TemplateEffects {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private matDialog: MatDialog,
|
private matDialog: MatDialog,
|
||||||
private appHookService: AppHookService,
|
|
||||||
private store: Store<AppStore>,
|
private store: Store<AppStore>,
|
||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
@@ -114,9 +114,9 @@ export class TemplateEffects {
|
|||||||
() =>
|
() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType<CreateFromTemplateSuccess>(TemplateActionTypes.CreateFromTemplateSuccess),
|
ofType<CreateFromTemplateSuccess>(TemplateActionTypes.CreateFromTemplateSuccess),
|
||||||
map((payload) => {
|
map(() => {
|
||||||
this.matDialog.closeAll();
|
this.matDialog.closeAll();
|
||||||
this.appHookService.reload.next(payload.node);
|
this.documentListService.reload();
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
|
@@ -25,8 +25,8 @@
|
|||||||
import { Router, ActivatedRoute } from '@angular/router';
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
|
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { AuthenticationService } from '@alfresco/adf-core';
|
import { AuthenticationService } from '@alfresco/adf-core';
|
||||||
import { UploadService, NodesApiService, DiscoveryApiService } from '@alfresco/adf-content-services';
|
import { UploadService, NodesApiService, DiscoveryApiService, DocumentListService } from '@alfresco/adf-content-services';
|
||||||
import { ClosePreviewAction, RefreshPreviewAction, ReloadDocumentListAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
import { ClosePreviewAction, RefreshPreviewAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
||||||
import { AcaViewerComponent } from './viewer.component';
|
import { AcaViewerComponent } from './viewer.component';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
@@ -42,7 +42,7 @@ import { Node } from '@alfresco/js-api';
|
|||||||
import { AcaViewerModule } from '../../viewer.module';
|
import { AcaViewerModule } from '../../viewer.module';
|
||||||
|
|
||||||
const apiError = `{
|
const apiError = `{
|
||||||
"error": {
|
"error": {
|
||||||
"errorKey":"EntityNotFound",
|
"errorKey":"EntityNotFound",
|
||||||
"statusCode":404,
|
"statusCode":404,
|
||||||
"briefSummary":"The entity with id: someId was not found",
|
"briefSummary":"The entity with id: someId was not found",
|
||||||
@@ -63,6 +63,7 @@ describe('AcaViewerComponent', () => {
|
|||||||
let uploadService: UploadService;
|
let uploadService: UploadService;
|
||||||
let nodesApiService: NodesApiService;
|
let nodesApiService: NodesApiService;
|
||||||
let appHookService: AppHookService;
|
let appHookService: AppHookService;
|
||||||
|
let documentListService: DocumentListService;
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -84,6 +85,7 @@ describe('AcaViewerComponent', () => {
|
|||||||
uploadService = TestBed.inject(UploadService);
|
uploadService = TestBed.inject(UploadService);
|
||||||
nodesApiService = TestBed.inject(NodesApiService);
|
nodesApiService = TestBed.inject(NodesApiService);
|
||||||
appHookService = TestBed.inject(AppHookService);
|
appHookService = TestBed.inject(AppHookService);
|
||||||
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -122,11 +124,11 @@ describe('AcaViewerComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reload document list and navigate to node location upon close', async () => {
|
it('should reload document list and navigate to node location upon close', async () => {
|
||||||
spyOn(store, 'dispatch');
|
spyOn(documentListService, 'reload');
|
||||||
|
|
||||||
component.onViewerVisibilityChanged();
|
component.onViewerVisibilityChanged();
|
||||||
|
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(new ReloadDocumentListAction());
|
expect(documentListService.reload).toHaveBeenCalled();
|
||||||
expect(component['navigateToFileLocation']).toHaveBeenCalled();
|
expect(component['navigateToFileLocation']).toHaveBeenCalled();
|
||||||
expect(router.navigateByUrl).toHaveBeenCalledWith(fakeLocation);
|
expect(router.navigateByUrl).toHaveBeenCalledWith(fakeLocation);
|
||||||
});
|
});
|
||||||
|
@@ -36,7 +36,6 @@ import {
|
|||||||
getAppSelection,
|
getAppSelection,
|
||||||
isInfoDrawerOpened,
|
isInfoDrawerOpened,
|
||||||
RefreshPreviewAction,
|
RefreshPreviewAction,
|
||||||
ReloadDocumentListAction,
|
|
||||||
SetCurrentNodeVersionAction,
|
SetCurrentNodeVersionAction,
|
||||||
SetSelectedNodesAction,
|
SetSelectedNodesAction,
|
||||||
ViewerActionTypes,
|
ViewerActionTypes,
|
||||||
@@ -44,14 +43,14 @@ import {
|
|||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions';
|
import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions';
|
||||||
import { Node, VersionEntry, VersionsApi } from '@alfresco/js-api';
|
import { Node, VersionEntry, VersionsApi } from '@alfresco/js-api';
|
||||||
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, HostListener, inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
|
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
|
||||||
import { AlfrescoApiService, AppConfigPipe, ViewerModule } from '@alfresco/adf-core';
|
import { AlfrescoApiService, AppConfigPipe, ViewerModule } from '@alfresco/adf-core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { from, Observable, Subject } from 'rxjs';
|
import { from, Observable, Subject } from 'rxjs';
|
||||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||||
import { Actions, ofType } from '@ngrx/effects';
|
import { Actions, ofType } from '@ngrx/effects';
|
||||||
import { AlfrescoViewerModule, NodesApiService, UploadService } from '@alfresco/adf-content-services';
|
import { AlfrescoViewerModule, DocumentListService, NodesApiService, UploadService } from '@alfresco/adf-content-services';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { ViewerService } from '../../services/viewer.service';
|
import { ViewerService } from '../../services/viewer.service';
|
||||||
|
|
||||||
@@ -65,6 +64,8 @@ import { ViewerService } from '../../services/viewer.service';
|
|||||||
host: { class: 'app-viewer' }
|
host: { class: 'app-viewer' }
|
||||||
})
|
})
|
||||||
export class AcaViewerComponent implements OnInit, OnDestroy {
|
export class AcaViewerComponent implements OnInit, OnDestroy {
|
||||||
|
private documentListService = inject(DocumentListService);
|
||||||
|
|
||||||
private _versionsApi: VersionsApi;
|
private _versionsApi: VersionsApi;
|
||||||
get versionsApi(): VersionsApi {
|
get versionsApi(): VersionsApi {
|
||||||
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
||||||
@@ -189,7 +190,7 @@ export class AcaViewerComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onViewerVisibilityChanged() {
|
onViewerVisibilityChanged() {
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
this.navigateToFileLocation();
|
this.navigateToFileLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DocumentListComponent, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
|
import { DocumentListComponent, DocumentListService, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
|
||||||
import { ShowHeaderMode } from '@alfresco/adf-core';
|
import { ShowHeaderMode } from '@alfresco/adf-core';
|
||||||
import { ContentActionRef, DocumentListPresetRef, SelectionState } from '@alfresco/adf-extensions';
|
import { ContentActionRef, DocumentListPresetRef, SelectionState } from '@alfresco/adf-extensions';
|
||||||
import { OnDestroy, OnInit, OnChanges, ViewChild, SimpleChanges, Directive, inject, HostListener } from '@angular/core';
|
import { OnDestroy, OnInit, OnChanges, ViewChild, SimpleChanges, Directive, inject, HostListener } from '@angular/core';
|
||||||
@@ -33,7 +33,6 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
import { DocumentBasePageService } from './document-base-page.service';
|
import { DocumentBasePageService } from './document-base-page.service';
|
||||||
import {
|
import {
|
||||||
AppStore,
|
AppStore,
|
||||||
ReloadDocumentListAction,
|
|
||||||
getCurrentFolder,
|
getCurrentFolder,
|
||||||
getAppSelection,
|
getAppSelection,
|
||||||
isInfoDrawerOpened,
|
isInfoDrawerOpened,
|
||||||
@@ -71,6 +70,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
isSmallScreen = false;
|
isSmallScreen = false;
|
||||||
selectedRowItemsCount = 0;
|
selectedRowItemsCount = 0;
|
||||||
|
|
||||||
|
protected documentListService = inject(DocumentListService);
|
||||||
protected settings = inject(AppSettingsService);
|
protected settings = inject(AppSettingsService);
|
||||||
protected extensions = inject(AppExtensionService);
|
protected extensions = inject(AppExtensionService);
|
||||||
protected content = inject(DocumentBasePageService);
|
protected content = inject(DocumentBasePageService);
|
||||||
@@ -187,7 +187,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
if (selectedNode) {
|
if (selectedNode) {
|
||||||
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
|
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
onAllFilterCleared() {
|
onAllFilterCleared() {
|
||||||
if (!this.isOutletPreviewUrl()) {
|
if (!this.isOutletPreviewUrl()) {
|
||||||
this.documentList.node = null;
|
this.documentList.node = null;
|
||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.documentListService.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,18 +24,15 @@
|
|||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { PageComponent } from './document-base-page.component';
|
import { PageComponent } from './document-base-page.component';
|
||||||
import { AppState, ReloadDocumentListAction, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
import { AppState, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
||||||
import { AppExtensionService, LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared';
|
import { AppExtensionService, LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared';
|
||||||
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||||
import { DocumentBasePageService } from './document-base-page.service';
|
import { DocumentBasePageService } from './document-base-page.service';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { DiscoveryApiService, DocumentListComponent } from '@alfresco/adf-content-services';
|
import { DiscoveryApiService, DocumentListComponent, DocumentListService } from '@alfresco/adf-content-services';
|
||||||
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
||||||
import { AuthModule } from '@alfresco/adf-core';
|
import { AuthModule } from '@alfresco/adf-core';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { MatDialogModule } from '@angular/material/dialog';
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
|
||||||
@@ -59,6 +56,7 @@ describe('PageComponent', () => {
|
|||||||
let component: TestComponent;
|
let component: TestComponent;
|
||||||
let store: Store<AppState>;
|
let store: Store<AppState>;
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
let fixture: ComponentFixture<TestComponent>;
|
||||||
|
let documentListService: DocumentListService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -72,6 +70,7 @@ describe('PageComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
fixture = TestBed.createComponent(TestComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
});
|
});
|
||||||
@@ -110,10 +109,10 @@ describe('PageComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reload if url does not contain viewer outlet', () => {
|
it('should reload if url does not contain viewer outlet', () => {
|
||||||
spyOn(store, 'dispatch');
|
spyOn(documentListService, 'reload');
|
||||||
|
|
||||||
component.reload();
|
component.reload();
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(new ReloadDocumentListAction());
|
expect(documentListService.reload).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set selection after reload if node is passed', () => {
|
it('should set selection after reload if node is passed', () => {
|
||||||
@@ -129,6 +128,8 @@ describe('PageComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should clear results onAllFilterCleared event', () => {
|
it('should clear results onAllFilterCleared event', () => {
|
||||||
|
spyOn(documentListService, 'reload');
|
||||||
|
|
||||||
component.documentList = {
|
component.documentList = {
|
||||||
node: {
|
node: {
|
||||||
list: {
|
list: {
|
||||||
@@ -141,7 +142,7 @@ describe('PageComponent', () => {
|
|||||||
|
|
||||||
component.onAllFilterCleared();
|
component.onAllFilterCleared();
|
||||||
expect(component.documentList.node).toBe(null);
|
expect(component.documentList.node).toBe(null);
|
||||||
expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(new ReloadDocumentListAction());
|
expect(documentListService.reload).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call onAllFilterCleared event if page is viewer outlet', () => {
|
it('should call onAllFilterCleared event if page is viewer outlet', () => {
|
||||||
@@ -212,7 +213,7 @@ describe('Info Drawer state', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [NoopAnimationsModule, HttpClientModule, RouterTestingModule, AuthModule.forRoot(), MatDialogModule],
|
imports: [LibTestingModule, AuthModule.forRoot(), MatDialogModule],
|
||||||
declarations: [TestComponent],
|
declarations: [TestComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
|
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
|
||||||
|
@@ -30,16 +30,6 @@ import { SiteEntry } from '@alfresco/js-api';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AppHookService {
|
export class AppHookService {
|
||||||
/**
|
|
||||||
* Gets emitted when reloads event fired
|
|
||||||
*/
|
|
||||||
reload = new Subject<any>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets emitted when user reset the node
|
|
||||||
*/
|
|
||||||
reset = new Subject<any>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets emitted when user delete the node
|
* Gets emitted when user delete the node
|
||||||
*/
|
*/
|
||||||
@@ -86,7 +76,7 @@ export class AppHookService {
|
|||||||
linksUnshared = new Subject<any>();
|
linksUnshared = new Subject<any>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets emitted when user mark the the favorite library
|
* Gets emitted when user mark the favorite library
|
||||||
*/
|
*/
|
||||||
favoriteLibraryToggle = new Subject<any>();
|
favoriteLibraryToggle = new Subject<any>();
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,7 @@ export class ToggleInfoDrawerAction implements Action {
|
|||||||
readonly type = AppActionTypes.ToggleInfoDrawer;
|
readonly type = AppActionTypes.ToggleInfoDrawer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated use @alfresco/adf-content-services/DocumentListService.reload() instead */
|
||||||
export class ReloadDocumentListAction implements Action {
|
export class ReloadDocumentListAction implements Action {
|
||||||
readonly type = AppActionTypes.ReloadDocumentList;
|
readonly type = AppActionTypes.ReloadDocumentList;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user