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:
@@ -26,18 +26,18 @@ import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { AppActionTypes, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store';
|
||||
import { AppHookService } from '@alfresco/aca-shared';
|
||||
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||
|
||||
@Injectable()
|
||||
export class AppEffects {
|
||||
constructor(private actions$: Actions, private appHookService: AppHookService) {}
|
||||
constructor(private actions$: Actions, private documentListService: DocumentListService) {}
|
||||
|
||||
reload = createEffect(
|
||||
() =>
|
||||
this.actions$.pipe(
|
||||
ofType<ReloadDocumentListAction>(AppActionTypes.ReloadDocumentList),
|
||||
map((action) => {
|
||||
this.appHookService.reload.next(action);
|
||||
map(() => {
|
||||
this.documentListService.reload();
|
||||
})
|
||||
),
|
||||
{ dispatch: false }
|
||||
@@ -47,8 +47,8 @@ export class AppEffects {
|
||||
() =>
|
||||
this.actions$.pipe(
|
||||
ofType<ResetSelectionAction>(AppActionTypes.ResetSelection),
|
||||
map((action) => {
|
||||
this.appHookService.reset.next(action);
|
||||
map(() => {
|
||||
this.documentListService.resetSelection();
|
||||
})
|
||||
),
|
||||
{ dispatch: false }
|
||||
|
@@ -33,14 +33,14 @@ import { of, Subject } from 'rxjs';
|
||||
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { CreateFromTemplateDialogComponent } from '../../dialogs/node-template/create-from-template.dialog';
|
||||
import { AppHookService } from '@alfresco/aca-shared';
|
||||
import { NotificationService } from '@alfresco/adf-core';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||
|
||||
describe('TemplateEffects', () => {
|
||||
let store: Store<any>;
|
||||
let nodeTemplateService: NodeTemplateService;
|
||||
let appHookService: AppHookService;
|
||||
let documentListService: DocumentListService;
|
||||
let templateEffects: TemplateEffects;
|
||||
let copyNodeSpy;
|
||||
let updateNodeSpy;
|
||||
@@ -91,7 +91,7 @@ describe('TemplateEffects', () => {
|
||||
store = TestBed.inject(Store);
|
||||
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
||||
templateEffects = TestBed.inject(TemplateEffects);
|
||||
appHookService = TestBed.inject(AppHookService);
|
||||
documentListService = TestBed.inject(DocumentListService);
|
||||
matDialog = TestBed.inject(MatDialog);
|
||||
subject = new Subject<Node[]>();
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('TemplateEffects', () => {
|
||||
showErrorSpy = spyOn(notificationService, 'showError');
|
||||
|
||||
spyOn(store, 'dispatch').and.callThrough();
|
||||
spyOn(appHookService.reload, 'next');
|
||||
spyOn(documentListService, 'reload').and.stub();
|
||||
spyOn(store, 'select').and.returnValue(of({ id: 'parent-id' }));
|
||||
spyOn(nodeTemplateService, 'selectTemplateDialog').and.returnValue(subject);
|
||||
|
||||
@@ -212,6 +212,6 @@ describe('TemplateEffects', () => {
|
||||
const TEST_NODE = { id: 'test-node-id' } as Node;
|
||||
store.dispatch(new CreateFromTemplateSuccess(TEST_NODE));
|
||||
tick();
|
||||
expect(appHookService.reload.next).toHaveBeenCalledWith(TEST_NODE);
|
||||
expect(documentListService.reload).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
@@ -37,14 +37,15 @@ import {
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-template.service';
|
||||
import { AlfrescoApiService, NotificationService } from '@alfresco/adf-core';
|
||||
import { AppHookService } from '@alfresco/aca-shared';
|
||||
import { from, Observable, of } from 'rxjs';
|
||||
import { NodeEntry, NodeBodyUpdate, Node, NodesApi } from '@alfresco/js-api';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||
|
||||
@Injectable()
|
||||
export class TemplateEffects {
|
||||
private notificationService = inject(NotificationService);
|
||||
private documentListService = inject(DocumentListService);
|
||||
|
||||
private _nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
@@ -54,7 +55,6 @@ export class TemplateEffects {
|
||||
|
||||
constructor(
|
||||
private matDialog: MatDialog,
|
||||
private appHookService: AppHookService,
|
||||
private store: Store<AppStore>,
|
||||
private apiService: AlfrescoApiService,
|
||||
private actions$: Actions,
|
||||
@@ -114,9 +114,9 @@ export class TemplateEffects {
|
||||
() =>
|
||||
this.actions$.pipe(
|
||||
ofType<CreateFromTemplateSuccess>(TemplateActionTypes.CreateFromTemplateSuccess),
|
||||
map((payload) => {
|
||||
map(() => {
|
||||
this.matDialog.closeAll();
|
||||
this.appHookService.reload.next(payload.node);
|
||||
this.documentListService.reload();
|
||||
})
|
||||
),
|
||||
{ dispatch: false }
|
||||
|
Reference in New Issue
Block a user