[ACA-4287] Move hooks to shared library (#2052)

* * move hooks

* * import fixed

* fix prod build

* * refactor hook service

* * fixed test

* * docs added

* * revert tsconfig

* * revert tsconfig

* * docs updated

* * fixed setting testing

* * lint fixed

* * remove duplicate actions
This commit is contained in:
Dharan 2021-04-29 13:50:25 +05:30 committed by GitHub
parent 4ebc7447f9
commit 759099bde7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 279 additions and 165 deletions

View File

@ -23,3 +23,4 @@ Learn how to extend the features of the Alfresco Content Application.
- [Custom extension loaders](/extending/custom-extension-loaders.md)
- [Tutorials](/extending/tutorials)
- [Redistributable libraries](/extending/redistributable-libraries)
- [Application Hook](/extending/application-hook)

View File

@ -0,0 +1,37 @@
---
Title: Application Hook
---
# Application Hook
The app exposes the user events (aka hooks) to implement the features.
Most of the application hooks are already exposed.
You can listen any events via `AppHookService`, similar to the following:
```ts
export class MyComponent {
constructor(private appHookService: AppHookService) {
this.appHookService.reload.subscribe(() => {
// reload the feature
});
}
}
```
Below is the list of public hooks you can use in the plugin:
| Version | Name | Details | Description |
| ------- | ---------------------- | ---------------------------------------------| -----------------------------------------------------------------------------------|
| 2.2.2 | reload | n/a | Reloads the details in the current page. |
| 2.2.2 | reset | n/a | Resets the document list. |
| 2.2.2 | nodesDeleted | n/a | Notifies the node deleted. |
| 2.2.2 | libraryDeleted | n/a | Notifies the library deleted. |
| 2.2.2 | libraryCreated | SiteEntry | Notifies the library created. |
| 2.2.2 | libraryUpdated | SiteEntry | Notifies the library updated. |
| 2.2.2 | libraryJoined | string | Notifies user joined to library. |
| 2.2.2 | libraryLeft | n/a | Notifies user left to library. |
| 2.2.2 | library400Error | n/a | Notifies library errored operation. |
| 2.2.2 | joinLibraryToggle | string | Notifies user toggled join library. |
| 2.2.2 | linksUnshared | n/a | Notifies the shared link unshared. |
| 2.2.2 | favoriteLibraryToggle | n/a | Notifies user toggle favorite library. |

View File

@ -28,7 +28,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreModule, setupTestBed, StorageService } from '@alfresco/adf-core';
import { AcaSettingsModule } from './settings.module';
import { By } from '@angular/platform-browser';
import { AppExtensionService, SettingsParameterRef, LibTestingModule } from '@alfresco/aca-shared';
import { AppExtensionService, initialState, LibTestingModule, SettingsParameterRef } from '@alfresco/aca-shared';
import { provideMockStore } from '@ngrx/store/testing';
describe('SettingsComponent', () => {
let fixture: ComponentFixture<SettingsComponent>;
@ -40,7 +41,8 @@ describe('SettingsComponent', () => {
let boolParam: SettingsParameterRef;
setupTestBed({
imports: [CoreModule.forRoot(), AcaSettingsModule, LibTestingModule]
imports: [CoreModule.forRoot(), AcaSettingsModule, LibTestingModule],
providers: [provideMockStore({ initialState })]
});
beforeEach(() => {

View File

@ -26,9 +26,10 @@
import { PaginationDirective } from './pagination.directive';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { UserPreferencesService, AppConfigService, PaginationComponent, PaginationModel, CoreTestingModule } from '@alfresco/adf-core';
import { LibTestingModule } from '../testing/lib-testing-module';
import { initialState, LibTestingModule } from '../testing/lib-testing-module';
import { SharedDirectivesModule } from './shared.directives.module';
import { TranslateModule } from '@ngx-translate/core';
import { provideMockStore } from '@ngrx/store/testing';
describe('PaginationDirective', () => {
let preferences: UserPreferencesService;
@ -39,7 +40,8 @@ describe('PaginationDirective', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), LibTestingModule, SharedDirectivesModule, CoreTestingModule]
imports: [TranslateModule.forRoot(), LibTestingModule, SharedDirectivesModule, CoreTestingModule],
providers: [provideMockStore({ initialState })]
});
preferences = TestBed.inject(UserPreferencesService);

View File

@ -0,0 +1,93 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { SiteEntry } from '@alfresco/js-api';
@Injectable({
providedIn: 'root'
})
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
*/
nodesDeleted = new Subject<any>();
/**
* Gets emitted when user delete the library
*/
libraryDeleted = new Subject<string>();
/**
* Gets emitted when user create the library
*/
libraryCreated = new Subject<SiteEntry>();
/**
* Gets emitted when user update the library
*/
libraryUpdated = new Subject<SiteEntry>();
/**
* Gets emitted when user join the library
*/
libraryJoined = new Subject<string>();
/**
* Gets emitted when user left the library
*/
libraryLeft = new Subject<string>();
/**
* Gets emitted when library throws 400 error code
*/
library400Error = new Subject<any>();
/**
* Gets emitted when user join the library
*/
joinLibraryToggle = new Subject<string>();
/**
* Gets emitted when user unlink the node
*/
linksUnshared = new Subject<any>();
/**
* Gets emitted when user mark the the favorite library
*/
favoriteLibraryToggle = new Subject<any>();
}

View File

@ -24,7 +24,7 @@
*/
import { TestBed } from '@angular/core/testing';
import { LibTestingModule } from '../testing/lib-testing-module';
import { initialState, LibTestingModule } from '../testing/lib-testing-module';
import { AppExtensionService } from './app.extension.service';
import { Store, Action } from '@ngrx/store';
import { AppStore } from '@alfresco/aca-shared/store';
@ -40,6 +40,7 @@ import {
NavBarGroupRef
} from '@alfresco/adf-extensions';
import { AppConfigService } from '@alfresco/adf-core';
import { provideMockStore } from '@ngrx/store/testing';
describe('AppExtensionService', () => {
let service: AppExtensionService;
@ -49,7 +50,8 @@ describe('AppExtensionService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [LibTestingModule]
imports: [LibTestingModule],
providers: [provideMockStore({ initialState })]
});
appConfigService = TestBed.inject(AppConfigService);

View File

@ -24,11 +24,12 @@
*/
import { TestBed } from '@angular/core/testing';
import { LibTestingModule } from '../testing/lib-testing-module';
import { initialState, LibTestingModule } from '../testing/lib-testing-module';
import { RouterExtensionService } from './router.extension.service';
import { ExtensionService } from '@alfresco/adf-extensions';
import { Router } from '@angular/router';
import { Type } from '@angular/core';
import { provideMockStore } from '@ngrx/store/testing';
describe('RouterExtensionService', () => {
let extensionService: ExtensionService;
@ -49,6 +50,7 @@ describe('RouterExtensionService', () => {
TestBed.configureTestingModule({
imports: [LibTestingModule],
providers: [
provideMockStore({ initialState }),
{
provide: ExtensionService,
useValue: {

View File

@ -38,7 +38,6 @@ import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { provideMockStore } from '@ngrx/store/testing';
import { CommonModule } from '@angular/common';
export const initialState = {
@ -92,7 +91,6 @@ export const initialState = {
PipeModule
],
providers: [
provideMockStore({ initialState }),
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: TranslationService, useClass: TranslationMock }
]

View File

@ -56,6 +56,7 @@ export * from './lib/services/content-api.service';
export * from './lib/services/node-permission.service';
export * from './lib/services/app.extension.service';
export * from './lib/services/router.extension.service';
export * from './lib/services/app-hook.service';
export * from './lib/utils/node.utils';
export * from './lib/shared.module';

View File

@ -31,8 +31,7 @@ export enum LibraryActionTypes {
Create = 'CREATE_LIBRARY',
Navigate = 'NAVIGATE_LIBRARY',
Update = 'UPDATE_LIBRARY',
Leave = 'LEAVE_LIBRARY',
Reload = 'RELOAD_LIBRARY'
Leave = 'LEAVE_LIBRARY'
}
export class DeleteLibraryAction implements Action {
@ -62,6 +61,3 @@ export class LeaveLibraryAction implements Action {
constructor(public payload?: string) {}
}
export class ReloadLibraryAction implements Action {
readonly type = LibraryActionTypes.Reload;
}

View File

@ -23,15 +23,14 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router } from '@angular/router';
import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigModule, UserPreferencesService } from '@alfresco/adf-core';
import { AlfrescoApiService, AppConfigModule, DataTableComponent, NodeFavoriteDirective, UserPreferencesService } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { FavoriteLibrariesComponent } from './favorite-libraries.component';
import { AppTestingModule } from '../../testing/app-testing.module';
import { ContentApiService } from '@alfresco/aca-shared';
import { ContentManagementService } from '../../services/content-management.service';
import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { EffectsModule } from '@ngrx/effects';
import { RouterEffects } from '@alfresco/aca-shared/store';
import { of, throwError } from 'rxjs';
@ -46,7 +45,7 @@ describe('FavoriteLibrariesComponent', () => {
let contentApiService: ContentApiService;
let router: Router;
let page;
let contentManagementService;
let appHookService: AppHookService;
beforeEach(() => {
page = {
@ -70,7 +69,7 @@ describe('FavoriteLibrariesComponent', () => {
alfrescoApi = TestBed.inject(AlfrescoApiService);
contentApiService = TestBed.inject(ContentApiService);
userPreference = TestBed.inject(UserPreferencesService);
contentManagementService = TestBed.inject(ContentManagementService);
appHookService = TestBed.inject(AppHookService);
alfrescoApi.reset();
router = TestBed.inject(Router);
@ -130,27 +129,27 @@ describe('FavoriteLibrariesComponent', () => {
});
it('should reload on libraryDeleted action', () => {
contentManagementService.libraryDeleted.next();
appHookService.libraryDeleted.next();
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
});
it('should reload on libraryUpdated action', () => {
contentManagementService.libraryUpdated.next();
appHookService.libraryUpdated.next();
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
});
it('should reload on favoriteLibraryToggle action', () => {
contentManagementService.favoriteLibraryToggle.next();
appHookService.favoriteLibraryToggle.next();
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
});
it('should reload on libraryJoined action', () => {
contentManagementService.libraryJoined.next();
appHookService.libraryJoined.next();
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
});
it('should reload on libraryLeft action', () => {
contentManagementService.libraryLeft.next();
appHookService.libraryLeft.next();
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
});
});

View File

@ -28,7 +28,7 @@ import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { Store } from '@ngrx/store';
import { SiteEntry, FavoritePaging, Pagination } from '@alfresco/js-api';
import { ContentManagementService } from '../../services/content-management.service';
import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { NavigateLibraryAction } from '@alfresco/aca-shared/store';
import { PageComponent } from '../page.component';
import { UserPreferencesService } from '@alfresco/adf-core';
@ -52,6 +52,7 @@ export class FavoriteLibrariesComponent extends PageComponent implements OnInit
content: ContentManagementService,
store: Store<any>,
extensions: AppExtensionService,
private appHookService: AppHookService,
private contentApiService: ContentApiService,
private breakpointObserver: BreakpointObserver,
private preferences: UserPreferencesService,
@ -66,11 +67,11 @@ export class FavoriteLibrariesComponent extends PageComponent implements OnInit
this.getList({ maxItems: this.preferences.paginationSize });
this.subscriptions = this.subscriptions.concat([
this.content.libraryDeleted.subscribe(() => this.reloadList()),
this.content.libraryUpdated.subscribe(() => this.reloadList()),
this.content.libraryJoined.subscribe(() => this.reloadList()),
this.content.libraryLeft.subscribe(() => this.reloadList()),
this.content.favoriteLibraryToggle.subscribe(() => this.reloadList()),
this.appHookService.libraryDeleted.subscribe(() => this.reloadList()),
this.appHookService.libraryUpdated.subscribe(() => this.reloadList()),
this.appHookService.libraryJoined.subscribe(() => this.reloadList()),
this.appHookService.libraryLeft.subscribe(() => this.reloadList()),
this.appHookService.favoriteLibraryToggle.subscribe(() => this.reloadList()),
this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;

View File

@ -30,7 +30,7 @@ import { Component, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { ContentManagementService } from '../../services/content-management.service';
import { PageComponent } from '../page.component';
import { AppExtensionService } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
@Component({
@ -45,6 +45,7 @@ export class LibrariesComponent extends PageComponent implements OnInit {
content: ContentManagementService,
store: Store<AppStore>,
extensions: AppExtensionService,
private appHookService: AppHookService,
private breakpointObserver: BreakpointObserver
) {
super(store, extensions, content);
@ -54,9 +55,9 @@ export class LibrariesComponent extends PageComponent implements OnInit {
super.ngOnInit();
this.subscriptions.push(
this.content.libraryDeleted.subscribe(() => this.reload()),
this.content.libraryUpdated.subscribe(() => this.reload()),
this.content.libraryLeft.subscribe(() => this.reload()),
this.appHookService.libraryDeleted.subscribe(() => this.reload()),
this.appHookService.libraryUpdated.subscribe(() => this.reload()),
this.appHookService.libraryLeft.subscribe(() => this.reload()),
this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => {
this.isSmallScreen = result.matches;

View File

@ -32,8 +32,7 @@ import { of, throwError } from 'rxjs';
import { EffectsModule } from '@ngrx/effects';
import { NodeEffects } from '../../store/effects/node.effects';
import { AppTestingModule } from '../../testing/app-testing.module';
import { ContentApiService } from '@alfresco/aca-shared';
import { ContentManagementService } from '../../services/content-management.service';
import { ContentApiService, AppHookService } from '@alfresco/aca-shared';
import { Store } from '@ngrx/store';
import { Node, NodePaging, FavoritePaging, SharedLinkPaging, PersonEntry, ResultSetPaging } from '@alfresco/js-api';
import { PreviewModule } from './preview.module';
@ -47,7 +46,7 @@ describe('PreviewComponent', () => {
let contentApi: ContentApiService;
let uploadService: UploadService;
let alfrescoApiService: AlfrescoApiService;
let contentManagementService: ContentManagementService;
let appHookService: AppHookService;
let store: Store<any>;
beforeEach(() => {
@ -64,7 +63,7 @@ describe('PreviewComponent', () => {
contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.inject(UploadService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
appHookService = TestBed.inject(AppHookService);
store = TestBed.inject(Store);
});
@ -619,7 +618,7 @@ describe('PreviewComponent', () => {
spyOn(component, 'navigateToFileLocation');
fixture.detectChanges();
await fixture.whenStable();
contentManagementService.nodesDeleted.next();
appHookService.nodesDeleted.next();
expect(component.navigateToFileLocation).toHaveBeenCalled();
});

View File

@ -31,7 +31,7 @@ import { UserPreferencesService, ObjectUtils, UploadService, AlfrescoApiService
import { Store } from '@ngrx/store';
import { AppStore, ClosePreviewAction, ViewerActionTypes, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { PageComponent } from '../page.component';
import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { ContentManagementService } from '../../services/content-management.service';
import { ContentActionRef, ViewerExtensionRef } from '@alfresco/adf-extensions';
import { SearchRequest } from '@alfresco/js-api';
@ -98,7 +98,8 @@ export class PreviewComponent extends PageComponent implements OnInit, OnDestroy
private location: Location,
store: Store<AppStore>,
extensions: AppExtensionService,
content: ContentManagementService
content: ContentManagementService,
private appHookService: AppHookService
) {
super(store, extensions, content);
}
@ -138,7 +139,7 @@ export class PreviewComponent extends PageComponent implements OnInit, OnDestroy
});
this.subscriptions = this.subscriptions.concat([
this.content.nodesDeleted.subscribe(() => this.navigateToFileLocation(true)),
this.appHookService.nodesDeleted.subscribe(() => this.navigateToFileLocation(true)),
this.uploadService.fileUploadDeleted.subscribe(() => this.navigateToFileLocation(true)),

View File

@ -29,15 +29,15 @@ import { SearchInputComponent } from './search-input.component';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { Actions, ofType } from '@ngrx/effects';
import { SearchByTermAction, SearchActionTypes } from '@alfresco/aca-shared/store';
import { AppHookService } from '@alfresco/aca-shared';
import { map } from 'rxjs/operators';
import { ContentManagementService } from '../../../services/content-management.service';
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
describe('SearchInputComponent', () => {
let fixture: ComponentFixture<SearchInputComponent>;
let component: SearchInputComponent;
let actions$: Actions;
let content: ContentManagementService;
let appHookService: AppHookService;
beforeEach(() => {
TestBed.configureTestingModule({
@ -49,14 +49,14 @@ describe('SearchInputComponent', () => {
actions$ = TestBed.inject(Actions);
fixture = TestBed.createComponent(SearchInputComponent);
content = TestBed.inject(ContentManagementService);
appHookService = TestBed.inject(AppHookService);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should change flag on library400Error event', () => {
expect(component.has400LibraryError).toBe(false);
content.library400Error.next();
appHookService.library400Error.next();
expect(component.has400LibraryError).toBe(true);
});
@ -68,7 +68,7 @@ describe('SearchInputComponent', () => {
it('should have library constraint on 400 error received', () => {
const libItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('libraries') > 0);
libItem.value = true;
content.library400Error.next();
appHookService.library400Error.next();
expect(component.hasLibraryConstraint()).toBe(true);
});

View File

@ -23,6 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { AppHookService } from '@alfresco/aca-shared';
import { AppStore, SearchByTermAction, SearchOptionIds, SearchOptionModel } from '@alfresco/aca-shared/store';
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { AppConfigService } from '@alfresco/adf-core';
@ -32,7 +33,6 @@ import { NavigationEnd, PRIMARY_OUTLET, Router, RouterEvent, UrlSegment, UrlSegm
import { Store } from '@ngrx/store';
import { Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';
import { ContentManagementService } from '../../../services/content-management.service';
import { SearchInputControlComponent } from '../search-input-control/search-input-control.component';
import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/search-libraries-query-builder.service';
@ -82,9 +82,9 @@ export class SearchInputComponent implements OnInit, OnDestroy {
private queryBuilder: SearchQueryBuilderService,
private queryLibrariesBuilder: SearchLibrariesQueryBuilderService,
private config: AppConfigService,
private content: ContentManagementService,
private router: Router,
private store: Store<AppStore>
private store: Store<AppStore>,
private appHookService: AppHookService
) {
this.searchOnChange = this.config.get<boolean>('search.aca:triggeredOnChange', true);
}
@ -101,7 +101,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
}
});
this.content.library400Error.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.appHookService.library400Error.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.has400LibraryError = true;
});
}

View File

@ -32,7 +32,7 @@ import { Store } from '@ngrx/store';
import { ContentManagementService } from '../../../services/content-management.service';
import { PageComponent } from '../../page.component';
import { SearchLibrariesQueryBuilderService } from './search-libraries-query-builder.service';
import { AppExtensionService } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
@Component({
@ -53,6 +53,7 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
private breakpointObserver: BreakpointObserver,
private librariesQueryBuilder: SearchLibrariesQueryBuilderService,
private route: ActivatedRoute,
private appHookService: AppHookService,
store: Store<AppStore>,
extensions: AppExtensionService,
content: ContentManagementService
@ -71,9 +72,9 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
this.columns = this.extensions.documentListPresets.searchLibraries || [];
this.subscriptions.push(
this.content.libraryJoined.subscribe(() => this.librariesQueryBuilder.update()),
this.content.libraryDeleted.subscribe(() => this.librariesQueryBuilder.update()),
this.content.libraryLeft.subscribe(() => this.librariesQueryBuilder.update()),
this.appHookService.libraryJoined.subscribe(() => this.librariesQueryBuilder.update()),
this.appHookService.libraryDeleted.subscribe(() => this.librariesQueryBuilder.update()),
this.appHookService.libraryLeft.subscribe(() => this.librariesQueryBuilder.update()),
this.librariesQueryBuilder.updated.subscribe(() => {
this.isLoading = true;
@ -92,7 +93,7 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
error: { statusCode }
} = JSON.parse(err.message);
if (statusCode === 400) {
this.content.library400Error.next();
this.appHookService.library400Error.next();
}
} catch (e) {}
}),

View File

@ -32,7 +32,7 @@ import { debounceTime } from 'rxjs/operators';
import { UploadService } from '@alfresco/adf-core';
import { Router } from '@angular/router';
import { MinimalNodeEntity } from '@alfresco/js-api';
import { AppExtensionService } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
@Component({
@ -47,6 +47,7 @@ export class SharedFilesComponent extends PageComponent implements OnInit {
store: Store<any>,
extensions: AppExtensionService,
content: ContentManagementService,
private appHookService: AppHookService,
private uploadService: UploadService,
private breakpointObserver: BreakpointObserver,
private router: Router
@ -58,7 +59,7 @@ export class SharedFilesComponent extends PageComponent implements OnInit {
super.ngOnInit();
this.subscriptions = this.subscriptions.concat([
this.content.linksUnshared.pipe(debounceTime(300)).subscribe(() => this.reload()),
this.appHookService.linksUnshared.pipe(debounceTime(300)).subscribe(() => this.reload()),
this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((_) => this.reload()),
this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((_) => this.reload()),

View File

@ -23,21 +23,21 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AlfrescoApiService, CoreModule } from '@alfresco/adf-core';
import { ToggleFavoriteLibraryComponent } from './toggle-favorite-library.component';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { ContentManagementService } from '../../../services/content-management.service';
import { of } from 'rxjs';
import { Router } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { AppHookService } from '@alfresco/aca-shared';
describe('ToggleFavoriteLibraryComponent', () => {
let fixture: ComponentFixture<ToggleFavoriteLibraryComponent>;
let component: ToggleFavoriteLibraryComponent;
let contentManagementService: ContentManagementService;
let appHookService: AppHookService;
const selection = { library: { entry: { id: 'libraryId' } } };
const mockRouter = {
@ -59,8 +59,7 @@ describe('ToggleFavoriteLibraryComponent', () => {
dispatch: () => {},
select: () => of(selection)
}
},
ContentManagementService
}
],
schemas: [NO_ERRORS_SCHEMA]
});
@ -70,7 +69,7 @@ describe('ToggleFavoriteLibraryComponent', () => {
fixture = TestBed.createComponent(ToggleFavoriteLibraryComponent);
component = fixture.componentInstance;
contentManagementService = TestBed.inject(ContentManagementService);
appHookService = TestBed.inject(AppHookService);
const api = TestBed.inject(AlfrescoApiService);
spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue(Promise.resolve(null));
});
@ -91,13 +90,13 @@ describe('ToggleFavoriteLibraryComponent', () => {
});
it('should emit onToggleEvent() event', async () => {
spyOn(contentManagementService.favoriteLibraryToggle, 'next');
spyOn(appHookService.favoriteLibraryToggle, 'next');
fixture.detectChanges();
await fixture.whenStable();
component.onToggleEvent();
expect(contentManagementService.favoriteLibraryToggle.next).toHaveBeenCalled();
expect(appHookService.favoriteLibraryToggle.next).toHaveBeenCalled();
});
});

View File

@ -25,9 +25,9 @@
import { Component, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppHookService } from '@alfresco/aca-shared';
import { AppStore, getAppSelection } from '@alfresco/aca-shared/store';
import { SelectionState } from '@alfresco/adf-extensions';
import { ContentManagementService } from '../../../services/content-management.service';
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
import { Router } from '@angular/router';
import { Subject } from 'rxjs';
@ -53,7 +53,7 @@ export class ToggleFavoriteLibraryComponent implements OnInit, OnDestroy {
library;
private onDestroy$: Subject<boolean> = new Subject<boolean>();
constructor(private store: Store<AppStore>, private content: ContentManagementService, private router: Router) {}
constructor(private store: Store<AppStore>, private appHookService: AppHookService, private router: Router) {}
ngOnInit() {
const isFavoriteLibraries = this.router.url.startsWith('/favorite/libraries');
@ -77,6 +77,6 @@ export class ToggleFavoriteLibraryComponent implements OnInit, OnDestroy {
}
onToggleEvent() {
this.content.favoriteLibraryToggle.next();
this.appHookService.favoriteLibraryToggle.next();
}
}

View File

@ -29,15 +29,14 @@ import {
SnackbarErrorAction,
SnackbarInfoAction,
getAppSelection,
getUserProfile,
ReloadLibraryAction
getUserProfile
} from '@alfresco/aca-shared/store';
import { AppHookService } from '@alfresco/aca-shared';
import { ProfileState, SelectionState } from '@alfresco/adf-extensions';
import { Component, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { LibraryMembershipErrorEvent, LibraryMembershipToggleEvent } from '@alfresco/adf-core';
import { ContentManagementService } from '../../../services/content-management.service';
@Component({
selector: 'app-toggle-join-library-button',
@ -63,7 +62,7 @@ export class ToggleJoinLibraryButtonComponent {
selection$: Observable<SelectionState>;
profile$: Observable<ProfileState>;
constructor(private store: Store<AppStore>, private content: ContentManagementService) {
constructor(private store: Store<AppStore>, private appHookService: AppHookService) {
this.selection$ = this.store.select(getAppSelection);
this.profile$ = this.store.select(getUserProfile);
}
@ -72,13 +71,12 @@ export class ToggleJoinLibraryButtonComponent {
this.store.dispatch(new SnackbarInfoAction(event.i18nKey));
if (event.shouldReload) {
this.content.libraryJoined.next();
this.store.dispatch(new ReloadLibraryAction());
this.appHookService.libraryJoined.next();
} else {
if (event.updatedEntry) {
this.store.dispatch(new SetSelectedNodesAction([{ entry: event.updatedEntry, isLibrary: true } as any]));
}
this.content.joinLibraryToggle.next();
this.appHookService.joinLibraryToggle.next();
}
}

View File

@ -25,8 +25,8 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppHookService } from '@alfresco/aca-shared';
import { AppStore } from '@alfresco/aca-shared/store';
import { ContentManagementService } from '../../../services/content-management.service';
import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.component';
@Component({
@ -49,7 +49,7 @@ import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.c
host: { class: 'app-toggle-join-library' }
})
export class ToggleJoinLibraryMenuComponent extends ToggleJoinLibraryButtonComponent {
constructor(store: Store<AppStore>, content: ContentManagementService) {
super(store, content);
constructor(store: Store<AppStore>, appHookService: AppHookService) {
super(store, appHookService);
}
}

View File

@ -28,16 +28,16 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AlfrescoApiService, DirectiveModule } from '@alfresco/adf-core';
import { Store } from '@ngrx/store';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ReloadLibraryAction, SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store';
import { SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { ContentManagementService } from '../../../services/content-management.service';
import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.component';
import { AppHookService } from '@alfresco/aca-shared';
describe('ToggleJoinLibraryComponent', () => {
let component: ToggleJoinLibraryButtonComponent;
let fixture: ComponentFixture<ToggleJoinLibraryButtonComponent>;
let alfrescoApi: AlfrescoApiService;
let contentManagementService: ContentManagementService;
let appHookService: AppHookService;
let store: Store<any>;
let entry;
@ -66,7 +66,7 @@ describe('ToggleJoinLibraryComponent', () => {
store = TestBed.inject(Store);
alfrescoApi = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
appHookService = TestBed.inject(AppHookService);
spyOn(alfrescoApi.peopleApi, 'getSiteMembershipRequest').and.stub();
@ -99,18 +99,11 @@ describe('ToggleJoinLibraryComponent', () => {
expect(store.dispatch).toHaveBeenCalledWith(new SnackbarInfoAction(event.i18nKey));
});
it('should dispatch `ReloadLibraryAction` action on onToggleEvent', () => {
const event = { shouldReload: true, i18nKey: 'SOME_i18nKey' };
component.onToggleEvent(event);
expect(store.dispatch).toHaveBeenCalledWith(new ReloadLibraryAction());
});
it('should call libraryJoined.next on contentManagementService onToggleEvent', (done) => {
spyOn(contentManagementService.libraryJoined, 'next').and.callThrough();
spyOn(appHookService.libraryJoined, 'next').and.callThrough();
contentManagementService.libraryJoined.subscribe(() => {
expect(contentManagementService.libraryJoined.next).toHaveBeenCalled();
appHookService.libraryJoined.subscribe(() => {
expect(appHookService.libraryJoined.next).toHaveBeenCalled();
done();
});
const event = { shouldReload: true, i18nKey: null };
@ -118,10 +111,10 @@ describe('ToggleJoinLibraryComponent', () => {
});
it('should call joinLibraryToggle.next on contentManagementService onToggleEvent', (done) => {
spyOn(contentManagementService.joinLibraryToggle, 'next').and.callThrough();
spyOn(appHookService.joinLibraryToggle, 'next').and.callThrough();
contentManagementService.joinLibraryToggle.subscribe(() => {
expect(contentManagementService.joinLibraryToggle.next).toHaveBeenCalled();
appHookService.joinLibraryToggle.subscribe(() => {
expect(appHookService.joinLibraryToggle.next).toHaveBeenCalled();
done();
});
const event = { shouldReload: false, i18nKey: null };

View File

@ -23,28 +23,27 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService, ContentApiService } from '@alfresco/aca-shared';
import {
AppStore,
ClosePreviewAction,
getRuleContext,
isInfoDrawerOpened,
SetSelectedNodesAction,
ClosePreviewAction,
ViewerActionTypes,
ViewNodeAction,
RefreshPreviewAction,
ReloadDocumentListAction,
SetCurrentNodeVersionAction,
RefreshPreviewAction
SetSelectedNodesAction,
ViewerActionTypes,
ViewNodeAction
} from '@alfresco/aca-shared/store';
import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions';
import { MinimalNodeEntryEntity, SearchRequest, VersionEntry } from '@alfresco/js-api';
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router, PRIMARY_OUTLET } from '@angular/router';
import { UserPreferencesService, ObjectUtils, UploadService, AlfrescoApiService } from '@alfresco/adf-core';
import { ContentManagementService } from '../../services/content-management.service';
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
import { AlfrescoApiService, ObjectUtils, UploadService, UserPreferencesService } from '@alfresco/adf-core';
import { Store } from '@ngrx/store';
import { from, Observable, Subject } from 'rxjs';
import { takeUntil, debounceTime } from 'rxjs/operators';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { Actions, ofType } from '@ngrx/effects';
@Component({
@ -111,9 +110,9 @@ export class AppViewerComponent implements OnInit, OnDestroy {
private contentApi: ContentApiService,
private actions$: Actions,
private preferences: UserPreferencesService,
private content: ContentManagementService,
private apiService: AlfrescoApiService,
private uploadService: UploadService
private uploadService: UploadService,
private appHookService: AppHookService
) {}
ngOnInit() {
@ -178,7 +177,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
this.displayNode(action?.payload?.entry?.id);
});
this.content.nodesDeleted.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.navigateToFileLocation());
this.appHookService.nodesDeleted.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.navigateToFileLocation());
this.uploadService.fileUploadDeleted.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.navigateToFileLocation());

View File

@ -52,7 +52,7 @@ describe('DocumentListDirective', () => {
url: ''
};
const contentManagementServiceMock: any = {
const appHookServiceMock: any = {
reload: new Subject<any>(),
reset: new Subject<any>()
};
@ -73,11 +73,11 @@ describe('DocumentListDirective', () => {
beforeEach(() => {
documentListDirective = new DocumentListDirective(
storeMock,
contentManagementServiceMock,
documentListMock,
userPreferencesServiceMock,
mockRoute,
mockRouter
mockRouter,
appHookServiceMock
);
});
@ -138,7 +138,7 @@ describe('DocumentListDirective', () => {
it('should reset and reload document list on `reload` event', () => {
documentListDirective.ngOnInit();
contentManagementServiceMock.reload.next();
appHookServiceMock.reload.next();
expect(documentListMock.resetSelection).toHaveBeenCalled();
expect(documentListMock.reload).toHaveBeenCalled();
@ -146,14 +146,14 @@ describe('DocumentListDirective', () => {
it('should reset store selection on `reload` event', () => {
documentListDirective.ngOnInit();
contentManagementServiceMock.reload.next();
appHookServiceMock.reload.next();
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));
});
it('should reset selection state on `reset` event', () => {
documentListDirective.ngOnInit();
contentManagementServiceMock.reset.next();
appHookServiceMock.reset.next();
expect(documentListMock.resetSelection).toHaveBeenCalled();
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([]));

View File

@ -29,9 +29,9 @@ import { ActivatedRoute, Router } from '@angular/router';
import { UserPreferencesService } from '@alfresco/adf-core';
import { Subject } from 'rxjs';
import { Store } from '@ngrx/store';
import { AppHookService } from '@alfresco/aca-shared';
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { takeUntil, filter } from 'rxjs/operators';
import { ContentManagementService } from '../services/content-management.service';
import { MinimalNodeEntity } from '@alfresco/js-api';
@Directive({
@ -49,11 +49,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
constructor(
private store: Store<any>,
private content: ContentManagementService,
private documentList: DocumentListComponent,
private preferences: UserPreferencesService,
private route: ActivatedRoute,
private router: Router
private router: Router,
private appHookService: AppHookService
) {}
ngOnInit() {
@ -83,11 +83,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
)
.subscribe(() => this.onReady());
this.content.reload.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.appHookService.reload.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.reload(this.selectedNode);
});
this.content.reset.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.appHookService.reset.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.reset();
});
}

View File

@ -46,7 +46,7 @@ import {
import { map } from 'rxjs/operators';
import { NodeEffects } from '../store/effects/node.effects';
import { AppTestingModule } from '../testing/app-testing.module';
import { ContentApiService } from '@alfresco/aca-shared';
import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { Store } from '@ngrx/store';
import { ContentManagementService } from './content-management.service';
import { NodeActionsService } from './node-actions.service';
@ -67,6 +67,7 @@ describe('ContentManagementService', () => {
let translationService: TranslationService;
let alfrescoApiService: AlfrescoApiService;
let nodeAspectService: NodeAspectService;
let appHookService: AppHookService;
beforeEach(() => {
TestBed.configureTestingModule({
@ -82,6 +83,7 @@ describe('ContentManagementService', () => {
translationService = TestBed.inject(TranslationService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
nodeAspectService = TestBed.inject(NodeAspectService);
appHookService = TestBed.inject(AppHookService);
dialog = TestBed.inject(MatDialog);
});
@ -1420,7 +1422,7 @@ describe('ContentManagementService', () => {
it('should emit event when node is un-shared', fakeAsync(() => {
const node = { entry: { id: '1', name: 'name1' } } as NodeEntry;
spyOn(contentManagementService.linksUnshared, 'next').and.callThrough();
spyOn(appHookService.linksUnshared, 'next').and.callThrough();
spyOn(dialog, 'open').and.returnValue({
afterClosed: () => of(node)
} as MatDialogRef<MatDialog>);
@ -1429,7 +1431,7 @@ describe('ContentManagementService', () => {
tick();
flush();
expect(contentManagementService.linksUnshared.next).toHaveBeenCalled();
expect(appHookService.linksUnshared.next).toHaveBeenCalled();
}));
});

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ContentApiService, NodePermissionService } from '@alfresco/aca-shared';
import { AppHookService, ContentApiService, NodePermissionService } from '@alfresco/aca-shared';
import {
AppStore,
DeletedNodeInfo,
@ -64,7 +64,7 @@ import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Store } from '@ngrx/store';
import { forkJoin, Observable, of, Subject, zip } from 'rxjs';
import { forkJoin, Observable, of, zip } from 'rxjs';
import { catchError, map, mergeMap, take, tap } from 'rxjs/operators';
import { NodeVersionsDialogComponent } from '../dialogs/node-versions/node-versions.dialog';
import { NodeActionsService } from './node-actions.service';
@ -79,19 +79,6 @@ interface RestoredNode {
providedIn: 'root'
})
export class ContentManagementService {
reload = new Subject<any>();
reset = new Subject<any>();
nodesDeleted = new Subject<any>();
libraryDeleted = new Subject<string>();
libraryCreated = new Subject<SiteEntry>();
libraryUpdated = new Subject<SiteEntry>();
libraryJoined = new Subject<string>();
libraryLeft = new Subject<string>();
library400Error = new Subject<any>();
joinLibraryToggle = new Subject<string>();
linksUnshared = new Subject<any>();
favoriteLibraryToggle = new Subject<any>();
constructor(
private alfrescoApiService: AlfrescoApiService,
private store: Store<AppStore>,
@ -101,7 +88,8 @@ export class ContentManagementService {
private nodeActionsService: NodeActionsService,
private translation: TranslationService,
private snackBar: MatSnackBar,
private nodeAspectService: NodeAspectService
private nodeAspectService: NodeAspectService,
private appHookService: AppHookService
) {}
addFavorite(nodes: Array<MinimalNodeEntity>) {
@ -228,7 +216,7 @@ export class ContentManagementService {
.afterClosed()
.subscribe(() => {
this.store.dispatch(new SetSelectedNodesAction([node]));
this.linksUnshared.next();
this.appHookService.linksUnshared.next();
});
});
}
@ -289,7 +277,7 @@ export class ContentManagementService {
return dialogInstance.afterClosed().pipe(
tap((node) => {
if (node) {
this.libraryCreated.next(node);
this.appHookService.libraryCreated.next(node);
}
}),
map((node: SiteEntry) => {
@ -304,7 +292,7 @@ export class ContentManagementService {
deleteLibrary(id: string): void {
this.contentApi.deleteSite(id).subscribe(
() => {
this.libraryDeleted.next(id);
this.appHookService.libraryDeleted.next(id);
this.store.dispatch(new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED'));
},
() => {
@ -328,7 +316,7 @@ export class ContentManagementService {
if (result === true) {
this.contentApi.leaveSite(siteId).subscribe(
() => {
this.libraryLeft.next(siteId);
this.appHookService.libraryLeft.next(siteId);
this.store.dispatch(new SnackbarInfoAction('APP.MESSAGES.INFO.LEFT_LIBRARY'));
},
() => {
@ -342,7 +330,7 @@ export class ContentManagementService {
updateLibrary(siteId: string, siteBody: SiteBody) {
this.contentApi.updateLibrary(siteId, siteBody).subscribe(
(siteEntry: SiteEntry) => {
this.libraryUpdated.next(siteEntry);
this.appHookService.libraryUpdated.next(siteEntry);
this.store.dispatch(new SnackbarInfoAction('LIBRARY.SUCCESS.LIBRARY_UPDATED'));
},
() => {
@ -354,7 +342,7 @@ export class ContentManagementService {
async unshareNodes(links: Array<MinimalNodeEntity>) {
const promises = links.map((link) => this.contentApi.deleteSharedLink(link.entry.id).toPromise());
await Promise.all(promises);
this.linksUnshared.next();
this.appHookService.linksUnshared.next();
}
canUpdateNode(node: MinimalNodeEntity | Node): boolean {
@ -503,7 +491,7 @@ export class ContentManagementService {
forkJoin(...batch).subscribe(
() => {
this.nodesDeleted.next(null);
this.appHookService.nodesDeleted.next(null);
this.store.dispatch(new ReloadDocumentListAction());
},
(error) => {
@ -606,7 +594,7 @@ export class ContentManagementService {
this.store.dispatch(message);
if (status.someSucceeded) {
this.nodesDeleted.next();
this.appHookService.nodesDeleted.next();
this.store.dispatch(new ReloadDocumentListAction());
}
});

View File

@ -29,17 +29,17 @@ import { map } from 'rxjs/operators';
import { AppActionTypes, LogoutAction, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store';
import { AuthenticationService } from '@alfresco/adf-core';
import { Router } from '@angular/router';
import { ContentManagementService } from '../../services/content-management.service';
import { AppHookService } from '@alfresco/aca-shared';
@Injectable()
export class AppEffects {
constructor(private actions$: Actions, private auth: AuthenticationService, private router: Router, private content: ContentManagementService) {}
constructor(private actions$: Actions, private auth: AuthenticationService, private router: Router, private appHookService: AppHookService) {}
@Effect({ dispatch: false })
reload = this.actions$.pipe(
ofType<ReloadDocumentListAction>(AppActionTypes.ReloadDocumentList),
map((action) => {
this.content.reload.next(action);
this.appHookService.reload.next(action);
})
);
@ -47,7 +47,7 @@ export class AppEffects {
resetSelection = this.actions$.pipe(
ofType<ResetSelectionAction>(AppActionTypes.ResetSelection),
map((action) => {
this.content.reset.next(action);
this.appHookService.reset.next(action);
})
);

View File

@ -33,8 +33,7 @@ import {
NavigateRouteAction,
SnackbarErrorAction,
UpdateLibraryAction,
getAppSelection,
ReloadLibraryAction
getAppSelection
} from '@alfresco/aca-shared/store';
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
@ -87,7 +86,6 @@ export class LibraryEffects {
}
});
}
this.store.dispatch(new ReloadLibraryAction());
})
);

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
import { AppTestingModule } from '../../testing/app-testing.module';
import { TemplateEffects } from './template.effects';
import { EffectsModule } from '@ngrx/effects';
@ -32,16 +32,16 @@ import { CreateFromTemplate, CreateFromTemplateSuccess, FileFromTemplate, Folder
import { NodeTemplateService } from '../../services/node-template.service';
import { of, Subject } from 'rxjs';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { ContentManagementService } from '../../services/content-management.service';
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';
describe('TemplateEffects', () => {
let store: Store<any>;
let nodeTemplateService: NodeTemplateService;
let alfrescoApiService: AlfrescoApiService;
let contentManagementService: ContentManagementService;
let appHookService: AppHookService;
let copyNodeSpy;
let updateNodeSpy;
let matDialog: MatDialog;
@ -89,12 +89,12 @@ describe('TemplateEffects', () => {
store = TestBed.inject(Store);
nodeTemplateService = TestBed.inject(NodeTemplateService);
alfrescoApiService = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
appHookService = TestBed.inject(AppHookService);
matDialog = TestBed.inject(MatDialog);
subject = new Subject<Node[]>();
spyOn(store, 'dispatch').and.callThrough();
spyOn(contentManagementService.reload, 'next');
spyOn(appHookService.reload, 'next');
spyOn(store, 'select').and.returnValue(of({ id: 'parent-id' }));
spyOn(nodeTemplateService, 'selectTemplateDialog').and.returnValue(subject);
@ -219,6 +219,6 @@ describe('TemplateEffects', () => {
const test_node = { id: 'test-node-id' } as Node;
store.dispatch(new CreateFromTemplateSuccess(test_node));
tick();
expect(contentManagementService.reload.next).toHaveBeenCalledWith(test_node);
expect(appHookService.reload.next).toHaveBeenCalledWith(test_node);
}));
});

View File

@ -39,7 +39,7 @@ import {
} from '@alfresco/aca-shared/store';
import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-template.service';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { ContentManagementService } from '../../services/content-management.service';
import { AppHookService } from '@alfresco/aca-shared';
import { from, Observable, of } from 'rxjs';
import { NodeEntry, NodeBodyUpdate, Node } from '@alfresco/js-api';
import { MatDialog } from '@angular/material/dialog';
@ -48,7 +48,7 @@ import { MatDialog } from '@angular/material/dialog';
export class TemplateEffects {
constructor(
private matDialog: MatDialog,
private content: ContentManagementService,
private appHookService: AppHookService,
private store: Store<AppStore>,
private apiService: AlfrescoApiService,
private actions$: Actions,
@ -102,7 +102,7 @@ export class TemplateEffects {
ofType<CreateFromTemplateSuccess>(TemplateActionTypes.CreateFromTemplateSuccess),
map((payload) => {
this.matDialog.closeAll();
this.content.reload.next(payload.node);
this.appHookService.reload.next(payload.node);
})
);