mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-19 17:14:45 +00:00
[ADF-5429] Remove old compatibility layer (#2251)
* Remove old compatibility layer
This commit is contained in:
parent
1063f5e63e
commit
4c0e6b8861
@ -3,7 +3,7 @@ import:
|
|||||||
- source: .travis/env.yml
|
- source: .travis/env.yml
|
||||||
mode: deep_merge_prepend
|
mode: deep_merge_prepend
|
||||||
# =================
|
# =================
|
||||||
# merge anchor
|
# merge anchor
|
||||||
# =================
|
# =================
|
||||||
|
|
||||||
dist: bionic
|
dist: bionic
|
||||||
@ -85,7 +85,7 @@ jobs:
|
|||||||
name: 'Unit tests: ACA'
|
name: 'Unit tests: ACA'
|
||||||
script:
|
script:
|
||||||
- npm ci
|
- npm ci
|
||||||
- ng test app --code-coverage --watch=false
|
- ng test app --watch=false
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- stage: e2e
|
- stage: e2e
|
||||||
|
21504
package-lock.json
generated
21504
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -24,9 +24,9 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alfresco/adf-content-services": "4.6.0-33193",
|
"@alfresco/adf-content-services": "4.6.0-33212",
|
||||||
"@alfresco/adf-core": "4.6.0-33193",
|
"@alfresco/adf-core": "4.6.0-33212",
|
||||||
"@alfresco/adf-extensions": "4.6.0-33193",
|
"@alfresco/adf-extensions": "4.6.0-33212",
|
||||||
"@alfresco/js-api": "4.6.0-3694",
|
"@alfresco/js-api": "4.6.0-3694",
|
||||||
"@angular/animations": "10.0.4",
|
"@angular/animations": "10.0.4",
|
||||||
"@angular/cdk": "^10.0.2",
|
"@angular/cdk": "^10.0.2",
|
||||||
@ -56,8 +56,8 @@
|
|||||||
"zone.js": "~0.10.2"
|
"zone.js": "~0.10.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@alfresco/adf-cli": "4.6.0-33193",
|
"@alfresco/adf-cli": "4.6.0-33212",
|
||||||
"@alfresco/adf-testing": "4.6.0-33193",
|
"@alfresco/adf-testing": "4.6.0-33212",
|
||||||
"@angular-custom-builders/lite-serve": "^0.2.3",
|
"@angular-custom-builders/lite-serve": "^0.2.3",
|
||||||
"@angular-devkit/build-angular": "^0.1002.0",
|
"@angular-devkit/build-angular": "^0.1002.0",
|
||||||
"@angular-devkit/build-ng-packagr": "^0.1002.0",
|
"@angular-devkit/build-ng-packagr": "^0.1002.0",
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { AuthenticationService, AppConfigService } from '@alfresco/adf-core';
|
import { AuthenticationService, AppConfigService, AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||||
@ -40,6 +40,7 @@ describe('AppService', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [HttpClientModule],
|
imports: [HttpClientModule],
|
||||||
providers: [
|
providers: [
|
||||||
|
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||||
SearchQueryBuilderService,
|
SearchQueryBuilderService,
|
||||||
{
|
{
|
||||||
provide: AuthenticationService,
|
provide: AuthenticationService,
|
||||||
|
@ -41,7 +41,16 @@ import {
|
|||||||
SiteBody,
|
SiteBody,
|
||||||
SiteEntry,
|
SiteEntry,
|
||||||
FavoriteBody,
|
FavoriteBody,
|
||||||
FavoriteEntry
|
FavoriteEntry,
|
||||||
|
NodesApi,
|
||||||
|
TrashcanApi,
|
||||||
|
SharedlinksApi,
|
||||||
|
DiscoveryApi,
|
||||||
|
FavoritesApi,
|
||||||
|
ContentApi,
|
||||||
|
SitesApi,
|
||||||
|
SearchApi,
|
||||||
|
PeopleApi
|
||||||
} from '@alfresco/js-api';
|
} from '@alfresco/js-api';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -49,7 +58,27 @@ import { map } from 'rxjs/operators';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ContentApiService {
|
export class ContentApiService {
|
||||||
constructor(private api: AlfrescoApiService, private preferences: UserPreferencesService) {}
|
private nodesApi: NodesApi;
|
||||||
|
private trashcanApi: TrashcanApi;
|
||||||
|
private sharedLinksApi: SharedlinksApi;
|
||||||
|
private discoveryApi: DiscoveryApi;
|
||||||
|
private favoritesApi: FavoritesApi;
|
||||||
|
private contentApi: ContentApi;
|
||||||
|
private sitesApi: SitesApi;
|
||||||
|
private searchApi: SearchApi;
|
||||||
|
private peopleApi: PeopleApi;
|
||||||
|
|
||||||
|
constructor(private api: AlfrescoApiService, private preferences: UserPreferencesService) {
|
||||||
|
this.nodesApi = new NodesApi(this.api.getInstance());
|
||||||
|
this.trashcanApi = new TrashcanApi(this.api.getInstance());
|
||||||
|
this.sharedLinksApi = new SharedlinksApi(this.api.getInstance());
|
||||||
|
this.discoveryApi = new DiscoveryApi(this.api.getInstance());
|
||||||
|
this.favoritesApi = new FavoritesApi(this.api.getInstance());
|
||||||
|
this.contentApi = new ContentApi(this.api.getInstance());
|
||||||
|
this.sitesApi = new SitesApi(this.api.getInstance());
|
||||||
|
this.searchApi = new SearchApi(this.api.getInstance());
|
||||||
|
this.peopleApi = new PeopleApi(this.api.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves a node to the trashcan.
|
* Moves a node to the trashcan.
|
||||||
@ -58,7 +87,7 @@ export class ContentApiService {
|
|||||||
* @returns Empty result that notifies when the deletion is complete
|
* @returns Empty result that notifies when the deletion is complete
|
||||||
*/
|
*/
|
||||||
deleteNode(nodeId: string, options: { permanent?: boolean } = {}): Observable<void> {
|
deleteNode(nodeId: string, options: { permanent?: boolean } = {}): Observable<void> {
|
||||||
return from(this.api.nodesApi.deleteNode(nodeId, options));
|
return from(this.nodesApi.deleteNode(nodeId, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +102,7 @@ export class ContentApiService {
|
|||||||
};
|
};
|
||||||
const queryOptions = Object.assign(defaults, options);
|
const queryOptions = Object.assign(defaults, options);
|
||||||
|
|
||||||
return from(this.api.nodesApi.getNode(nodeId, queryOptions));
|
return from(this.nodesApi.getNode(nodeId, queryOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
getNodeInfo(nodeId: string, options?: any): Observable<Node> {
|
getNodeInfo(nodeId: string, options?: any): Observable<Node> {
|
||||||
@ -82,7 +111,19 @@ export class ContentApiService {
|
|||||||
};
|
};
|
||||||
const queryOptions = Object.assign(defaults, options || {});
|
const queryOptions = Object.assign(defaults, options || {});
|
||||||
|
|
||||||
return from(this.api.nodesApi.getNodeInfo(nodeId, queryOptions));
|
// @ts-ignore
|
||||||
|
return from(
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
this.nodesApi.getNode(nodeId, queryOptions).then(
|
||||||
|
(nodeEntry: NodeEntry) => {
|
||||||
|
resolve(nodeEntry.entry);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,11 +140,11 @@ export class ContentApiService {
|
|||||||
};
|
};
|
||||||
const queryOptions = Object.assign(defaults, options);
|
const queryOptions = Object.assign(defaults, options);
|
||||||
|
|
||||||
return from(this.api.nodesApi.getNodeChildren(nodeId, queryOptions));
|
return from(this.nodesApi.listNodeChildren(nodeId, queryOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSharedLink(linkId: string): Observable<any> {
|
deleteSharedLink(linkId: string): Observable<any> {
|
||||||
return from(this.api.sharedLinksApi.deleteSharedLink(linkId));
|
return from(this.sharedLinksApi.deleteSharedLink(linkId));
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeletedNodes(options: any = {}): Observable<DeletedNodesPaging> {
|
getDeletedNodes(options: any = {}): Observable<DeletedNodesPaging> {
|
||||||
@ -112,15 +153,15 @@ export class ContentApiService {
|
|||||||
};
|
};
|
||||||
const queryOptions = Object.assign(defaults, options);
|
const queryOptions = Object.assign(defaults, options);
|
||||||
|
|
||||||
return from(this.api.nodesApi.getDeletedNodes(queryOptions));
|
return from(this.trashcanApi.listDeletedNodes(queryOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreNode(nodeId: string): Observable<MinimalNodeEntity> {
|
restoreNode(nodeId: string): Observable<MinimalNodeEntity> {
|
||||||
return from(this.api.nodesApi.restoreNode(nodeId));
|
return from(this.trashcanApi.restoreDeletedNode(nodeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
purgeDeletedNode(nodeId: string): Observable<any> {
|
purgeDeletedNode(nodeId: string): Observable<any> {
|
||||||
return from(this.api.nodesApi.purgeDeletedNode(nodeId));
|
return from(this.trashcanApi.deleteDeletedNode(nodeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +171,7 @@ export class ContentApiService {
|
|||||||
* @returns User information
|
* @returns User information
|
||||||
*/
|
*/
|
||||||
getPerson(personId: string, options?: { fields?: Array<string> }): Observable<PersonEntry> {
|
getPerson(personId: string, options?: { fields?: Array<string> }): Observable<PersonEntry> {
|
||||||
return from(this.api.peopleApi.getPerson(personId, options));
|
return from(this.peopleApi.getPerson(personId, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +183,7 @@ export class ContentApiService {
|
|||||||
* @param opts Api options
|
* @param opts Api options
|
||||||
*/
|
*/
|
||||||
copyNode(nodeId: string, targetParentId: string, name?: string, opts?: { include?: Array<string>; fields?: Array<string> }): Observable<NodeEntry> {
|
copyNode(nodeId: string, targetParentId: string, name?: string, opts?: { include?: Array<string>; fields?: Array<string> }): Observable<NodeEntry> {
|
||||||
return from(this.api.nodesApi.copyNode(nodeId, { targetParentId, name }, opts));
|
return from(this.nodesApi.copyNode(nodeId, { targetParentId, name }, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +191,7 @@ export class ContentApiService {
|
|||||||
* @returns ProductVersionModel containing product details
|
* @returns ProductVersionModel containing product details
|
||||||
*/
|
*/
|
||||||
getRepositoryInformation(): Observable<DiscoveryEntry> {
|
getRepositoryInformation(): Observable<DiscoveryEntry> {
|
||||||
return from(this.api.getInstance().discovery.discoveryApi.getRepositoryInformation());
|
return from(this.discoveryApi.getRepositoryInformation());
|
||||||
}
|
}
|
||||||
|
|
||||||
getFavorites(
|
getFavorites(
|
||||||
@ -162,7 +203,7 @@ export class ContentApiService {
|
|||||||
fields?: Array<string>;
|
fields?: Array<string>;
|
||||||
}
|
}
|
||||||
): Observable<FavoritePaging> {
|
): Observable<FavoritePaging> {
|
||||||
return from(this.api.favoritesApi.getFavorites(personId, opts));
|
return from(this.favoritesApi.listFavorites(personId, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
getFavoriteLibraries(personId: string = '-me-', opts?: any): Observable<FavoritePaging> {
|
getFavoriteLibraries(personId: string = '-me-', opts?: any): Observable<FavoritePaging> {
|
||||||
@ -187,31 +228,31 @@ export class ContentApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findSharedLinks(opts?: any): Observable<SharedLinkPaging> {
|
findSharedLinks(opts?: any): Observable<SharedLinkPaging> {
|
||||||
return from(this.api.sharedLinksApi.findSharedLinks(opts));
|
return from(this.sharedLinksApi.listSharedLinks(opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSharedLinkContent(sharedId: string, attachment?: boolean): string {
|
getSharedLinkContent(sharedId: string, attachment?: boolean): string {
|
||||||
return this.api.contentApi.getSharedLinkContentUrl(sharedId, attachment);
|
return this.contentApi.getSharedLinkContentUrl(sharedId, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
search(request: SearchRequest): Observable<ResultSetPaging> {
|
search(request: SearchRequest): Observable<ResultSetPaging> {
|
||||||
return from(this.api.searchApi.search(request));
|
return from(this.searchApi.search(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
getContentUrl(nodeId: string, attachment?: boolean): string {
|
getContentUrl(nodeId: string, attachment?: boolean): string {
|
||||||
return this.api.contentApi.getContentUrl(nodeId, attachment);
|
return this.contentApi.getContentUrl(nodeId, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean): string {
|
getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean): string {
|
||||||
return this.api.contentApi.getVersionContentUrl(nodeId, versionId, attachment);
|
return this.contentApi.getVersionContentUrl(nodeId, versionId, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSite(siteId?: string, opts?: { permanent?: boolean }): Observable<any> {
|
deleteSite(siteId?: string, opts?: { permanent?: boolean }): Observable<any> {
|
||||||
return from(this.api.sitesApi.deleteSite(siteId, opts));
|
return from(this.sitesApi.deleteSite(siteId, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
leaveSite(siteId?: string): Observable<any> {
|
leaveSite(siteId?: string): Observable<any> {
|
||||||
return from(this.api.sitesApi.removeSiteMember(siteId, '-me-'));
|
return from(this.sitesApi.deleteSiteMembership(siteId, '-me-'));
|
||||||
}
|
}
|
||||||
|
|
||||||
createSite(
|
createSite(
|
||||||
@ -222,15 +263,15 @@ export class ContentApiService {
|
|||||||
skipAddToFavorites?: boolean;
|
skipAddToFavorites?: boolean;
|
||||||
}
|
}
|
||||||
): Observable<SiteEntry> {
|
): Observable<SiteEntry> {
|
||||||
return from(this.api.sitesApi.createSite(siteBody, opts));
|
return from(this.sitesApi.createSite(siteBody, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSite(siteId?: string, opts?: { relations?: Array<string>; fields?: Array<string> }): Observable<SiteEntry> {
|
getSite(siteId?: string, opts?: { relations?: Array<string>; fields?: Array<string> }): Observable<SiteEntry> {
|
||||||
return from(this.api.sitesApi.getSite(siteId, opts));
|
return from(this.sitesApi.getSite(siteId, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary(siteId: string, siteBody: SiteBody): Observable<SiteEntry> {
|
updateLibrary(siteId: string, siteBody: SiteBody): Observable<SiteEntry> {
|
||||||
return from(this.api.sitesApi.updateSite(siteId, siteBody));
|
return from(this.sitesApi.updateSite(siteId, siteBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
addFavorite(nodes: Array<MinimalNodeEntity>): Observable<FavoriteEntry> {
|
addFavorite(nodes: Array<MinimalNodeEntity>): Observable<FavoriteEntry> {
|
||||||
@ -249,7 +290,7 @@ export class ContentApiService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return from(this.api.favoritesApi.addFavorite('-me-', payload as any));
|
return from(this.favoritesApi.createFavorite('-me-', payload as any));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFavorite(nodes: Array<MinimalNodeEntity>): Observable<any> {
|
removeFavorite(nodes: Array<MinimalNodeEntity>): Observable<any> {
|
||||||
@ -257,13 +298,13 @@ export class ContentApiService {
|
|||||||
Promise.all(
|
Promise.all(
|
||||||
nodes.map((node: any) => {
|
nodes.map((node: any) => {
|
||||||
const id = node.entry.nodeId || node.entry.id;
|
const id = node.entry.nodeId || node.entry.id;
|
||||||
return this.api.favoritesApi.removeFavoriteSite('-me-', id);
|
return this.favoritesApi.deleteFavorite('-me-', id);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockNode(nodeId: string, opts?: any) {
|
unlockNode(nodeId: string, opts?: any) {
|
||||||
return this.api.nodesApi.unlockNode(nodeId, opts);
|
return this.nodesApi.unlockNode(nodeId, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,10 @@ import { UpdateLibraryAction } from '@alfresco/aca-shared/store';
|
|||||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { Site, SitePaging } from '@alfresco/js-api';
|
import { Site, SitePaging } from '@alfresco/js-api';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
|
||||||
|
|
||||||
describe('LibraryMetadataFormComponent', () => {
|
describe('LibraryMetadataFormComponent', () => {
|
||||||
let fixture: ComponentFixture<LibraryMetadataFormComponent>;
|
let fixture: ComponentFixture<LibraryMetadataFormComponent>;
|
||||||
let component: LibraryMetadataFormComponent;
|
let component: LibraryMetadataFormComponent;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -53,7 +51,6 @@ describe('LibraryMetadataFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(LibraryMetadataFormComponent);
|
fixture = TestBed.createComponent(LibraryMetadataFormComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@ -214,7 +211,7 @@ describe('LibraryMetadataFormComponent', () => {
|
|||||||
|
|
||||||
it('should warn if library name input is used by another library', fakeAsync(() => {
|
it('should warn if library name input is used by another library', fakeAsync(() => {
|
||||||
const title = 'some-title';
|
const title = 'some-title';
|
||||||
spyOn(alfrescoApiService.getInstance().core.queriesApi, 'findSites').and.returnValue(
|
spyOn(component['queriesApi'], 'findSites').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { title } }] }
|
list: { entries: [{ entry: { title } }] }
|
||||||
} as SitePaging)
|
} as SitePaging)
|
||||||
@ -242,7 +239,7 @@ describe('LibraryMetadataFormComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not warn if library name input is the same with library node data', fakeAsync(() => {
|
it('should not warn if library name input is the same with library node data', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.getInstance().core.queriesApi, 'findSites').and.returnValue(
|
spyOn(component['queriesApi'], 'findSites').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { title: 'libraryTitle' } }] }
|
list: { entries: [{ entry: { title: 'libraryTitle' } }] }
|
||||||
} as SitePaging)
|
} as SitePaging)
|
||||||
@ -270,7 +267,7 @@ describe('LibraryMetadataFormComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not warn if library name is unique', fakeAsync(() => {
|
it('should not warn if library name is unique', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.getInstance().core.queriesApi, 'findSites').and.returnValue(
|
spyOn(component['queriesApi'], 'findSites').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [] }
|
list: { entries: [] }
|
||||||
} as SitePaging)
|
} as SitePaging)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import { Component, Input, OnInit, OnChanges, OnDestroy } from '@angular/core';
|
import { Component, Input, OnInit, OnChanges, OnDestroy } from '@angular/core';
|
||||||
import { FormGroup, FormControl, Validators, FormGroupDirective, NgForm } from '@angular/forms';
|
import { FormGroup, FormControl, Validators, FormGroupDirective, NgForm } from '@angular/forms';
|
||||||
import { SiteEntry, SitePaging } from '@alfresco/js-api';
|
import { QueriesApi, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppStore, UpdateLibraryAction } from '@alfresco/aca-shared/store';
|
import { AppStore, UpdateLibraryAction } from '@alfresco/aca-shared/store';
|
||||||
import { debounceTime, mergeMap, takeUntil } from 'rxjs/operators';
|
import { debounceTime, mergeMap, takeUntil } from 'rxjs/operators';
|
||||||
@ -45,6 +45,8 @@ export class InstantErrorStateMatcher implements ErrorStateMatcher {
|
|||||||
templateUrl: './library-metadata-form.component.html'
|
templateUrl: './library-metadata-form.component.html'
|
||||||
})
|
})
|
||||||
export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestroy {
|
export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
private queriesApi: QueriesApi;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
node: SiteEntry;
|
node: SiteEntry;
|
||||||
|
|
||||||
@ -68,7 +70,9 @@ export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestro
|
|||||||
|
|
||||||
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(private alfrescoApiService: AlfrescoApiService, protected store: Store<AppStore>) {}
|
constructor(private alfrescoApiService: AlfrescoApiService, protected store: Store<AppStore>) {
|
||||||
|
this.queriesApi = new QueriesApi(this.alfrescoApiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
get canUpdateLibrary() {
|
get canUpdateLibrary() {
|
||||||
return this.node && this.node.entry && this.node.entry.role === 'SiteManager';
|
return this.node && this.node.entry && this.node.entry.role === 'SiteManager';
|
||||||
@ -139,9 +143,8 @@ export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestro
|
|||||||
|
|
||||||
private findLibraryByTitle(libraryTitle: string): Observable<SitePaging | { list: { entries: any[] } }> {
|
private findLibraryByTitle(libraryTitle: string): Observable<SitePaging | { list: { entries: any[] } }> {
|
||||||
return from(
|
return from(
|
||||||
this.alfrescoApiService
|
this.queriesApi
|
||||||
.getInstance()
|
.findSites(libraryTitle, {
|
||||||
.core.queriesApi.findSites(libraryTitle, {
|
|
||||||
maxItems: 1,
|
maxItems: 1,
|
||||||
fields: ['title']
|
fields: ['title']
|
||||||
})
|
})
|
||||||
|
@ -32,11 +32,13 @@ import { LibrariesComponent } from './libraries.component';
|
|||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
import { LibraryEffects } from '../../store/effects';
|
import { LibraryEffects } from '../../store/effects';
|
||||||
|
import { ContentApiService } from '@alfresco/aca-shared';
|
||||||
|
|
||||||
describe('LibrariesComponent', () => {
|
describe('LibrariesComponent', () => {
|
||||||
let fixture: ComponentFixture<LibrariesComponent>;
|
let fixture: ComponentFixture<LibrariesComponent>;
|
||||||
let component: LibrariesComponent;
|
let component: LibrariesComponent;
|
||||||
let alfrescoApi: AlfrescoApiService;
|
let alfrescoApi: AlfrescoApiService;
|
||||||
|
let contentApiService: ContentApiService;
|
||||||
let router: Router;
|
let router: Router;
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
@ -60,11 +62,14 @@ describe('LibrariesComponent', () => {
|
|||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
alfrescoApi = TestBed.inject(AlfrescoApiService);
|
alfrescoApi = TestBed.inject(AlfrescoApiService);
|
||||||
|
contentApiService = TestBed.inject(ContentApiService);
|
||||||
alfrescoApi.reset();
|
alfrescoApi.reset();
|
||||||
router = TestBed.inject(Router);
|
router = TestBed.inject(Router);
|
||||||
|
|
||||||
spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue(Promise.resolve(page));
|
const sitesApi: any = contentApiService['sitesApi'];
|
||||||
spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve({}));
|
|
||||||
|
spyOn(sitesApi, 'listSites').and.returnValue(Promise.resolve(page));
|
||||||
|
spyOn(sitesApi, 'listSiteMembershipsForPerson').and.returnValue(Promise.resolve({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Node navigation', () => {
|
describe('Node navigation', () => {
|
||||||
|
@ -41,8 +41,8 @@ describe('SearchLibrariesQueryBuilderService', () => {
|
|||||||
|
|
||||||
apiService = TestBed.inject(AlfrescoApiService);
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
apiService.reset();
|
apiService.reset();
|
||||||
queriesApi = apiService.getInstance().core.queriesApi;
|
|
||||||
builder = new SearchLibrariesQueryBuilderService(apiService);
|
builder = new SearchLibrariesQueryBuilderService(apiService);
|
||||||
|
queriesApi = builder['queriesApi'];
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have empty user query by default', () => {
|
it('should have empty user query by default', () => {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { SitePaging } from '@alfresco/js-api';
|
import { QueriesApi, SitePaging } from '@alfresco/js-api';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
export interface LibrarySearchQuery {
|
export interface LibrarySearchQuery {
|
||||||
@ -41,6 +41,7 @@ export interface LibrarySearchQuery {
|
|||||||
})
|
})
|
||||||
export class SearchLibrariesQueryBuilderService {
|
export class SearchLibrariesQueryBuilderService {
|
||||||
private _userQuery = '';
|
private _userQuery = '';
|
||||||
|
private queriesApi: QueriesApi;
|
||||||
|
|
||||||
updated: Subject<any> = new Subject();
|
updated: Subject<any> = new Subject();
|
||||||
executed: Subject<any> = new Subject();
|
executed: Subject<any> = new Subject();
|
||||||
@ -56,7 +57,9 @@ export class SearchLibrariesQueryBuilderService {
|
|||||||
this._userQuery = value ? value.trim() : '';
|
this._userQuery = value ? value.trim() : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private alfrescoApiService: AlfrescoApiService) {}
|
constructor(private alfrescoApiService: AlfrescoApiService) {
|
||||||
|
this.queriesApi = new QueriesApi(this.alfrescoApiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
update(): void {
|
update(): void {
|
||||||
const query = this.buildQuery();
|
const query = this.buildQuery();
|
||||||
@ -89,12 +92,9 @@ export class SearchLibrariesQueryBuilderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private findLibraries(libraryQuery: LibrarySearchQuery): Promise<SitePaging> {
|
private findLibraries(libraryQuery: LibrarySearchQuery): Promise<SitePaging> {
|
||||||
return this.alfrescoApiService
|
return this.queriesApi.findSites(libraryQuery.term, libraryQuery.opts).catch((err) => {
|
||||||
.getInstance()
|
this.hadError.next(err);
|
||||||
.core.queriesApi.findSites(libraryQuery.term, libraryQuery.opts)
|
return { list: { pagination: { totalItems: 0 }, entries: [] } };
|
||||||
.catch((err) => {
|
});
|
||||||
this.hadError.next(err);
|
|
||||||
return { list: { pagination: { totalItems: 0 }, entries: [] } };
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin
|
|||||||
import { SearchResultsComponent } from './search-results.component';
|
import { SearchResultsComponent } from './search-results.component';
|
||||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||||
import { AppSearchResultsModule } from '../search-results.module';
|
import { AppSearchResultsModule } from '../search-results.module';
|
||||||
import { AlfrescoApiService, AppConfigService, CoreModule, TranslationService } from '@alfresco/adf-core';
|
import { AppConfigService, CoreModule, TranslationService } from '@alfresco/adf-core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { NavigateToFolder, SnackbarErrorAction } from '@alfresco/aca-shared/store';
|
import { NavigateToFolder, SnackbarErrorAction } from '@alfresco/aca-shared/store';
|
||||||
import { Pagination, SearchRequest } from '@alfresco/js-api';
|
import { Pagination, SearchRequest } from '@alfresco/js-api';
|
||||||
@ -42,7 +42,6 @@ describe('SearchComponent', () => {
|
|||||||
let config: AppConfigService;
|
let config: AppConfigService;
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
let queryBuilder: SearchQueryBuilderService;
|
let queryBuilder: SearchQueryBuilderService;
|
||||||
let alfrescoApi: AlfrescoApiService;
|
|
||||||
let translate: TranslationService;
|
let translate: TranslationService;
|
||||||
let router: Router;
|
let router: Router;
|
||||||
const searchRequest = {} as SearchRequest;
|
const searchRequest = {} as SearchRequest;
|
||||||
@ -70,7 +69,6 @@ describe('SearchComponent', () => {
|
|||||||
config = TestBed.inject(AppConfigService);
|
config = TestBed.inject(AppConfigService);
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
queryBuilder = TestBed.inject(SearchQueryBuilderService);
|
queryBuilder = TestBed.inject(SearchQueryBuilderService);
|
||||||
alfrescoApi = TestBed.inject(AlfrescoApiService);
|
|
||||||
translate = TestBed.inject(TranslationService);
|
translate = TestBed.inject(TranslationService);
|
||||||
router = TestBed.inject(Router);
|
router = TestBed.inject(Router);
|
||||||
|
|
||||||
@ -91,7 +89,7 @@ describe('SearchComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should raise an error if search fails', fakeAsync(() => {
|
it('should raise an error if search fails', fakeAsync(() => {
|
||||||
spyOn(alfrescoApi.searchApi, 'search').and.returnValue(
|
spyOn(queryBuilder['searchApi'], 'search').and.returnValue(
|
||||||
Promise.reject({
|
Promise.reject({
|
||||||
message: `{ "error": { "statusCode": 500 } } `
|
message: `{ "error": { "statusCode": 500 } } `
|
||||||
})
|
})
|
||||||
@ -114,7 +112,7 @@ describe('SearchComponent', () => {
|
|||||||
return key;
|
return key;
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(alfrescoApi.searchApi, 'search').and.returnValue(
|
spyOn(queryBuilder['searchApi'], 'search').and.returnValue(
|
||||||
Promise.reject({
|
Promise.reject({
|
||||||
message: `{ "error": { "statusCode": 401 } } `
|
message: `{ "error": { "statusCode": 401 } } `
|
||||||
})
|
})
|
||||||
@ -137,7 +135,7 @@ describe('SearchComponent', () => {
|
|||||||
return key;
|
return key;
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(alfrescoApi.searchApi, 'search').and.returnValue(
|
spyOn(queryBuilder['searchApi'], 'search').and.returnValue(
|
||||||
Promise.reject({
|
Promise.reject({
|
||||||
message: `{ "error": { "statusCode": 401 } } `
|
message: `{ "error": { "statusCode": 401 } } `
|
||||||
})
|
})
|
||||||
|
@ -30,14 +30,12 @@ import { AppTestingModule } from '../../testing/app-testing.module';
|
|||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
|
||||||
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
||||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||||
|
|
||||||
describe('SharedLinkViewComponent', () => {
|
describe('SharedLinkViewComponent', () => {
|
||||||
let component: SharedLinkViewComponent;
|
let component: SharedLinkViewComponent;
|
||||||
let fixture: ComponentFixture<SharedLinkViewComponent>;
|
let fixture: ComponentFixture<SharedLinkViewComponent>;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
|
||||||
let appExtensionService: AppExtensionService;
|
let appExtensionService: AppExtensionService;
|
||||||
let spyGetSharedLink;
|
let spyGetSharedLink;
|
||||||
const storeMock = {
|
const storeMock = {
|
||||||
@ -52,14 +50,6 @@ describe('SharedLinkViewComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
AppExtensionService,
|
AppExtensionService,
|
||||||
{ provide: Store, useValue: storeMock },
|
{ provide: Store, useValue: storeMock },
|
||||||
{
|
|
||||||
provide: AlfrescoApiService,
|
|
||||||
useValue: {
|
|
||||||
sharedLinksApi: {
|
|
||||||
getSharedLink: () => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
provide: ActivatedRoute,
|
provide: ActivatedRoute,
|
||||||
useValue: {
|
useValue: {
|
||||||
@ -73,10 +63,9 @@ describe('SharedLinkViewComponent', () => {
|
|||||||
|
|
||||||
fixture = TestBed.createComponent(SharedLinkViewComponent);
|
fixture = TestBed.createComponent(SharedLinkViewComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
|
||||||
appExtensionService = TestBed.inject(AppExtensionService);
|
appExtensionService = TestBed.inject(AppExtensionService);
|
||||||
|
|
||||||
spyGetSharedLink = spyOn(alfrescoApiService.sharedLinksApi, 'getSharedLink');
|
spyGetSharedLink = spyOn(component['sharedLinksApi'], 'getSharedLink');
|
||||||
|
|
||||||
storeMock.dispatch.calls.reset();
|
storeMock.dispatch.calls.reset();
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
import { AppStore, SetSelectedNodesAction, getAppSelection } from '@alfresco/aca-shared/store';
|
import { AppStore, SetSelectedNodesAction, getAppSelection } from '@alfresco/aca-shared/store';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
import { SharedLinkEntry } from '@alfresco/js-api';
|
import { SharedLinkEntry, SharedlinksApi } from '@alfresco/js-api';
|
||||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
@ -42,6 +42,7 @@ import { AppExtensionService } from '@alfresco/aca-shared';
|
|||||||
host: { class: 'app-shared-link-view' }
|
host: { class: 'app-shared-link-view' }
|
||||||
})
|
})
|
||||||
export class SharedLinkViewComponent implements OnInit {
|
export class SharedLinkViewComponent implements OnInit {
|
||||||
|
private sharedLinksApi: SharedlinksApi;
|
||||||
sharedLinkId: string = null;
|
sharedLinkId: string = null;
|
||||||
viewerToolbarActions: Array<ContentActionRef> = [];
|
viewerToolbarActions: Array<ContentActionRef> = [];
|
||||||
|
|
||||||
@ -50,15 +51,15 @@ export class SharedLinkViewComponent implements OnInit {
|
|||||||
private store: Store<AppStore>,
|
private store: Store<AppStore>,
|
||||||
private extensions: AppExtensionService,
|
private extensions: AppExtensionService,
|
||||||
private alfrescoApiService: AlfrescoApiService
|
private alfrescoApiService: AlfrescoApiService
|
||||||
) {}
|
) {
|
||||||
|
this.sharedLinksApi = new SharedlinksApi(this.alfrescoApiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params
|
this.route.params
|
||||||
.pipe(
|
.pipe(
|
||||||
mergeMap((params) =>
|
mergeMap((params) =>
|
||||||
forkJoin([from(this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id)), of(params.id)]).pipe(
|
forkJoin([from(this.sharedLinksApi.getSharedLink(params.id)), of(params.id)]).pipe(catchError(() => of([null, params.id])))
|
||||||
catchError(() => of([null, params.id]))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => {
|
.subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppStore, DownloadNodesAction, EditOfflineAction, SnackbarErrorAction, getAppSelection } from '@alfresco/aca-shared/store';
|
import { AppStore, DownloadNodesAction, EditOfflineAction, SnackbarErrorAction, getAppSelection } from '@alfresco/aca-shared/store';
|
||||||
import { MinimalNodeEntity, NodeEntry, SharedLinkEntry, Node } from '@alfresco/js-api';
|
import { MinimalNodeEntity, NodeEntry, SharedLinkEntry, Node, NodesApi } from '@alfresco/js-api';
|
||||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { isLocked } from '@alfresco/aca-shared';
|
import { isLocked } from '@alfresco/aca-shared';
|
||||||
@ -53,9 +53,12 @@ import { AlfrescoApiService } from '@alfresco/adf-core';
|
|||||||
host: { class: 'app-toggle-edit-offline' }
|
host: { class: 'app-toggle-edit-offline' }
|
||||||
})
|
})
|
||||||
export class ToggleEditOfflineComponent implements OnInit {
|
export class ToggleEditOfflineComponent implements OnInit {
|
||||||
|
private nodesApi: NodesApi;
|
||||||
selection: MinimalNodeEntity;
|
selection: MinimalNodeEntity;
|
||||||
|
|
||||||
constructor(private store: Store<AppStore>, private alfrescoApiService: AlfrescoApiService) {}
|
constructor(private store: Store<AppStore>, private alfrescoApiService: AlfrescoApiService) {
|
||||||
|
this.nodesApi = new NodesApi(this.alfrescoApiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.store.select(getAppSelection).subscribe(({ file }) => {
|
this.store.select(getAppSelection).subscribe(({ file }) => {
|
||||||
@ -113,14 +116,14 @@ export class ToggleEditOfflineComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lockNode(nodeId: string) {
|
lockNode(nodeId: string) {
|
||||||
return this.alfrescoApiService.nodesApi.lockNode(nodeId, {
|
return this.nodesApi.lockNode(nodeId, {
|
||||||
type: 'ALLOW_OWNER_CHANGES',
|
type: 'ALLOW_OWNER_CHANGES',
|
||||||
lifetime: 'PERSISTENT'
|
lifetime: 'PERSISTENT'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockNode(nodeId: string) {
|
unlockNode(nodeId: string) {
|
||||||
return this.alfrescoApiService.nodesApi.unlockNode(nodeId);
|
return this.nodesApi.unlockNode(nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private update(data: Node) {
|
private update(data: Node) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { AlfrescoApiService, CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
import { ToggleFavoriteLibraryComponent } from './toggle-favorite-library.component';
|
import { ToggleFavoriteLibraryComponent } from './toggle-favorite-library.component';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
@ -32,12 +32,13 @@ import { AppTestingModule } from '../../../testing/app-testing.module';
|
|||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
|
||||||
|
|
||||||
describe('ToggleFavoriteLibraryComponent', () => {
|
describe('ToggleFavoriteLibraryComponent', () => {
|
||||||
let fixture: ComponentFixture<ToggleFavoriteLibraryComponent>;
|
let fixture: ComponentFixture<ToggleFavoriteLibraryComponent>;
|
||||||
let component: ToggleFavoriteLibraryComponent;
|
let component: ToggleFavoriteLibraryComponent;
|
||||||
let appHookService: AppHookService;
|
let appHookService: AppHookService;
|
||||||
|
let contentApiService: any;
|
||||||
|
|
||||||
const selection = { library: { entry: { id: 'libraryId' } } };
|
const selection = { library: { entry: { id: 'libraryId' } } };
|
||||||
const mockRouter = {
|
const mockRouter = {
|
||||||
@ -68,10 +69,10 @@ describe('ToggleFavoriteLibraryComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ToggleFavoriteLibraryComponent);
|
fixture = TestBed.createComponent(ToggleFavoriteLibraryComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
contentApiService = TestBed.inject(ContentApiService);
|
||||||
|
|
||||||
appHookService = TestBed.inject(AppHookService);
|
appHookService = TestBed.inject(AppHookService);
|
||||||
const api = TestBed.inject(AlfrescoApiService);
|
spyOn(contentApiService['favoritesApi'], 'getFavoriteSite').and.returnValue(Promise.resolve(null));
|
||||||
spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue(Promise.resolve(null));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get library selection from Store', async () => {
|
it('should get library selection from Store', async () => {
|
||||||
|
@ -25,19 +25,19 @@
|
|||||||
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { AlfrescoApiService, DirectiveModule } from '@alfresco/adf-core';
|
import { DirectiveModule } from '@alfresco/adf-core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store';
|
import { SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store';
|
||||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||||
import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.component';
|
import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.component';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
|
||||||
|
|
||||||
describe('ToggleJoinLibraryComponent', () => {
|
describe('ToggleJoinLibraryComponent', () => {
|
||||||
let component: ToggleJoinLibraryButtonComponent;
|
let component: ToggleJoinLibraryButtonComponent;
|
||||||
let fixture: ComponentFixture<ToggleJoinLibraryButtonComponent>;
|
let fixture: ComponentFixture<ToggleJoinLibraryButtonComponent>;
|
||||||
let alfrescoApi: AlfrescoApiService;
|
|
||||||
let appHookService: AppHookService;
|
let appHookService: AppHookService;
|
||||||
|
let contentApiService: any;
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
let entry;
|
let entry;
|
||||||
|
|
||||||
@ -65,13 +65,12 @@ describe('ToggleJoinLibraryComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
alfrescoApi = TestBed.inject(AlfrescoApiService);
|
|
||||||
appHookService = TestBed.inject(AppHookService);
|
appHookService = TestBed.inject(AppHookService);
|
||||||
|
|
||||||
spyOn(alfrescoApi.peopleApi, 'getSiteMembershipRequest').and.stub();
|
contentApiService = TestBed.inject(ContentApiService);
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ToggleJoinLibraryButtonComponent);
|
fixture = TestBed.createComponent(ToggleJoinLibraryButtonComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
spyOn(contentApiService['sitesApi'], 'getSiteMembershipRequestForPerson').and.stub();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -64,6 +64,6 @@ describe('TrashcanComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(alfrescoApi.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(page));
|
spyOn(component['nodesApi'], 'getDeletedNodes').and.returnValue(Promise.resolve(page));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,7 @@ import {
|
|||||||
ViewNodeAction
|
ViewNodeAction
|
||||||
} 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 { MinimalNodeEntryEntity, SearchRequest, VersionEntry } from '@alfresco/js-api';
|
import { MinimalNodeEntryEntity, SearchRequest, VersionEntry, VersionsApi } from '@alfresco/js-api';
|
||||||
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
|
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
|
||||||
import { AlfrescoApiService, ObjectUtils, UploadService, UserPreferencesService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, ObjectUtils, UploadService, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
@ -54,6 +54,8 @@ import { Actions, ofType } from '@ngrx/effects';
|
|||||||
host: { class: 'app-viewer' }
|
host: { class: 'app-viewer' }
|
||||||
})
|
})
|
||||||
export class AppViewerComponent implements OnInit, OnDestroy {
|
export class AppViewerComponent implements OnInit, OnDestroy {
|
||||||
|
private versionsApi: VersionsApi;
|
||||||
|
|
||||||
onDestroy$ = new Subject<boolean>();
|
onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
fileName: string;
|
fileName: string;
|
||||||
@ -113,7 +115,9 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private appHookService: AppHookService
|
private appHookService: AppHookService
|
||||||
) {}
|
) {
|
||||||
|
this.versionsApi = new VersionsApi(apiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened);
|
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened);
|
||||||
@ -144,7 +148,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
const { nodeId } = params;
|
const { nodeId } = params;
|
||||||
this.versionId = params.versionId;
|
this.versionId = params.versionId;
|
||||||
if (this.versionId) {
|
if (this.versionId) {
|
||||||
this.apiService.versionsApi.getVersion(nodeId, this.versionId).then((version: VersionEntry) => {
|
this.versionsApi.getVersion(nodeId, this.versionId).then((version: VersionEntry) => {
|
||||||
if (version) {
|
if (version) {
|
||||||
this.store.dispatch(new SetCurrentNodeVersionAction(version));
|
this.store.dispatch(new SetCurrentNodeVersionAction(version));
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ describe('NodeActionsService', () => {
|
|||||||
const permissionError = new Error(JSON.stringify({ error: { statusCode: 403 } }));
|
const permissionError = new Error(JSON.stringify({ error: { statusCode: 403 } }));
|
||||||
const badRequestError = new Error(JSON.stringify({ error: { statusCode: 400 } }));
|
const badRequestError = new Error(JSON.stringify({ error: { statusCode: 400 } }));
|
||||||
const emptyChildrenList = { list: { entries: [] } };
|
const emptyChildrenList = { list: { entries: [] } };
|
||||||
let service: NodeActionsService;
|
let service: any;
|
||||||
let apiService: AlfrescoApiService;
|
let apiService: AlfrescoApiService;
|
||||||
let nodesApi;
|
let nodesApi: any;
|
||||||
let spyOnSuccess: jasmine.Spy;
|
let spyOnSuccess: jasmine.Spy;
|
||||||
let spyOnError: jasmine.Spy;
|
let spyOnError: jasmine.Spy;
|
||||||
let contentApi: ContentApiService;
|
let contentApi: ContentApiService;
|
||||||
@ -112,7 +112,7 @@ describe('NodeActionsService', () => {
|
|||||||
dialog = TestBed.inject(MatDialog);
|
dialog = TestBed.inject(MatDialog);
|
||||||
apiService.reset();
|
apiService.reset();
|
||||||
|
|
||||||
nodesApi = apiService.getInstance().nodes;
|
nodesApi = service['nodesApi'];
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ContentNodeSelector configuration', () => {
|
describe('ContentNodeSelector configuration', () => {
|
||||||
@ -585,7 +585,7 @@ describe('NodeActionsService', () => {
|
|||||||
nodeChildren: [existingFolder]
|
nodeChildren: [existingFolder]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
spyOn(nodesApi, 'listNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
||||||
spyOn(service, 'getChildByName').and.returnValue(of(existingFolder) as any);
|
spyOn(service, 'getChildByName').and.returnValue(of(existingFolder) as any);
|
||||||
|
|
||||||
copyObservable
|
copyObservable
|
||||||
@ -631,7 +631,7 @@ describe('NodeActionsService', () => {
|
|||||||
nodeChildren: [existingFolder]
|
nodeChildren: [existingFolder]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
spyOn(nodesApi, 'listNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
||||||
spyOn(service, 'getChildByName').and.returnValue(of({}) as any);
|
spyOn(service, 'getChildByName').and.returnValue(of({}) as any);
|
||||||
|
|
||||||
copyObservable
|
copyObservable
|
||||||
@ -673,7 +673,7 @@ describe('NodeActionsService', () => {
|
|||||||
nodeChildren: [existingFolder]
|
nodeChildren: [existingFolder]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
spyOn(nodesApi, 'listNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
||||||
spyOn(service, 'getChildByName').and.returnValue(of(existingFolder) as any);
|
spyOn(service, 'getChildByName').and.returnValue(of(existingFolder) as any);
|
||||||
|
|
||||||
copyObservable
|
copyObservable
|
||||||
@ -861,7 +861,7 @@ describe('NodeActionsService', () => {
|
|||||||
|
|
||||||
const subject$ = new Subject<NodeChildAssociationEntry>();
|
const subject$ = new Subject<NodeChildAssociationEntry>();
|
||||||
spyOn(service, 'getChildByName').and.returnValue(subject$);
|
spyOn(service, 'getChildByName').and.returnValue(subject$);
|
||||||
spyOn(service, 'getNodeChildren').and.returnValue(of(emptyChildrenList));
|
spyOn(nodesApi, 'listNodeChildren').and.returnValue(of(emptyChildrenList));
|
||||||
|
|
||||||
service.moveFolderAction(folderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError);
|
service.moveFolderAction(folderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError);
|
||||||
|
|
||||||
@ -885,7 +885,7 @@ describe('NodeActionsService', () => {
|
|||||||
const subject$ = new Subject<NodeChildAssociationEntry>();
|
const subject$ = new Subject<NodeChildAssociationEntry>();
|
||||||
spyOn(service, 'getChildByName').and.returnValue(subject$);
|
spyOn(service, 'getChildByName').and.returnValue(subject$);
|
||||||
const childrenNodes = [fileToMove, folderToMove];
|
const childrenNodes = [fileToMove, folderToMove];
|
||||||
spyOn(service, 'getNodeChildren').and.returnValue(of({ list: { entries: childrenNodes } }));
|
spyOn(nodesApi, 'listNodeChildren').and.returnValue(of({ list: { entries: childrenNodes } }));
|
||||||
|
|
||||||
service.moveFolderAction(parentFolderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError);
|
service.moveFolderAction(parentFolderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError);
|
||||||
subject$.next(newDestination);
|
subject$.next(newDestination);
|
||||||
@ -1019,7 +1019,7 @@ describe('NodeActionsService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emits child node with specified name, when it exists in folder', (done) => {
|
it('emits child node with specified name, when it exists in folder', (done) => {
|
||||||
spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
spyOn(nodesApi, 'listNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
||||||
|
|
||||||
service.getChildByName(testFamilyNodes[0].parentNodeId, childNode.entry.name).subscribe((value) => {
|
service.getChildByName(testFamilyNodes[0].parentNodeId, childNode.entry.name).subscribe((value) => {
|
||||||
expect(value).toEqual(childNode);
|
expect(value).toEqual(childNode);
|
||||||
@ -1028,7 +1028,7 @@ describe('NodeActionsService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emits null value when child with specified name is not found in folder', (done) => {
|
it('emits null value when child with specified name is not found in folder', (done) => {
|
||||||
spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
spyOn(nodesApi, 'listNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes));
|
||||||
|
|
||||||
service.getChildByName(testFamilyNodes[0].parentNodeId, notChildNode.entry.name).subscribe((value) => {
|
service.getChildByName(testFamilyNodes[0].parentNodeId, notChildNode.entry.name).subscribe((value) => {
|
||||||
expect(value).toEqual(null);
|
expect(value).toEqual(null);
|
||||||
@ -1037,7 +1037,7 @@ describe('NodeActionsService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emits error when permission error occurs', (done) => {
|
it('emits error when permission error occurs', (done) => {
|
||||||
spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes, actionIsForbidden));
|
spyOn(nodesApi, 'listNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes, actionIsForbidden));
|
||||||
|
|
||||||
service.getChildByName(testFamilyNodes[0].parentNodeId, notChildNode.entry.name).subscribe(
|
service.getChildByName(testFamilyNodes[0].parentNodeId, notChildNode.entry.name).subscribe(
|
||||||
() => {},
|
() => {},
|
||||||
|
@ -35,7 +35,14 @@ import {
|
|||||||
ShareDataRow,
|
ShareDataRow,
|
||||||
NodeAction
|
NodeAction
|
||||||
} from '@alfresco/adf-content-services';
|
} from '@alfresco/adf-content-services';
|
||||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, SitePaging, NodeChildAssociationPaging, NodeChildAssociationEntry } from '@alfresco/js-api';
|
import {
|
||||||
|
MinimalNodeEntity,
|
||||||
|
MinimalNodeEntryEntity,
|
||||||
|
SitePaging,
|
||||||
|
NodeChildAssociationPaging,
|
||||||
|
NodeChildAssociationEntry,
|
||||||
|
NodesApi
|
||||||
|
} from '@alfresco/js-api';
|
||||||
import { ContentApiService } from '@alfresco/aca-shared';
|
import { ContentApiService } from '@alfresco/aca-shared';
|
||||||
import { catchError, map, mergeMap } from 'rxjs/operators';
|
import { catchError, map, mergeMap } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -50,6 +57,8 @@ export class NodeActionsService {
|
|||||||
moveDeletedEntries: any[] = [];
|
moveDeletedEntries: any[] = [];
|
||||||
isSitesDestinationAvailable = false;
|
isSitesDestinationAvailable = false;
|
||||||
|
|
||||||
|
private nodesApi: NodesApi;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private contentApi: ContentApiService,
|
private contentApi: ContentApiService,
|
||||||
@ -58,7 +67,9 @@ export class NodeActionsService {
|
|||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private translation: TranslationService,
|
private translation: TranslationService,
|
||||||
private thumbnailService: ThumbnailService
|
private thumbnailService: ThumbnailService
|
||||||
) {}
|
) {
|
||||||
|
this.nodesApi = new NodesApi(this.apiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy node list
|
* Copy node list
|
||||||
@ -595,7 +606,7 @@ export class NodeActionsService {
|
|||||||
* @param params optional parameters
|
* @param params optional parameters
|
||||||
*/
|
*/
|
||||||
getNodeChildren(nodeId: string, params?: any): Observable<NodeChildAssociationPaging> {
|
getNodeChildren(nodeId: string, params?: any): Observable<NodeChildAssociationPaging> {
|
||||||
return from(this.apiService.getInstance().nodes.getNodeChildren(nodeId, params));
|
return from(this.nodesApi.listNodeChildren(nodeId, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied from ADF document-list.service, and added the name parameter
|
// Copied from ADF document-list.service, and added the name parameter
|
||||||
@ -607,7 +618,7 @@ export class NodeActionsService {
|
|||||||
* @param name The new name for the copy that would be added on the destination folder
|
* @param name The new name for the copy that would be added on the destination folder
|
||||||
*/
|
*/
|
||||||
copyNode(nodeId: string, targetParentId: string, name?: string) {
|
copyNode(nodeId: string, targetParentId: string, name?: string) {
|
||||||
return from(this.apiService.getInstance().nodes.copyNode(nodeId, { targetParentId, name }));
|
return from(this.nodesApi.copyNode(nodeId, { targetParentId, name }));
|
||||||
}
|
}
|
||||||
|
|
||||||
public flatten(nDimArray: any[]) {
|
public flatten(nDimArray: any[]) {
|
||||||
|
@ -30,14 +30,12 @@ import { TemplateEffects } from '../store/effects/template.effects';
|
|||||||
import { AppTestingModule } from '../testing/app-testing.module';
|
import { AppTestingModule } from '../testing/app-testing.module';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
|
||||||
import { NodeTemplateService } from './node-template.service';
|
import { NodeTemplateService } from './node-template.service';
|
||||||
import { ResultSetPaging } from '@alfresco/js-api';
|
import { ResultSetPaging } from '@alfresco/js-api';
|
||||||
|
|
||||||
describe('NodeTemplateService', () => {
|
describe('NodeTemplateService', () => {
|
||||||
let dialog: MatDialog;
|
let dialog: MatDialog;
|
||||||
let store: Store<AppStore>;
|
let store: Store<AppStore>;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
|
||||||
let nodeTemplateService: NodeTemplateService;
|
let nodeTemplateService: NodeTemplateService;
|
||||||
const fileTemplateConfig = {
|
const fileTemplateConfig = {
|
||||||
primaryPathName: 'parent-file-templates',
|
primaryPathName: 'parent-file-templates',
|
||||||
@ -55,13 +53,12 @@ describe('NodeTemplateService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
|
||||||
dialog = TestBed.inject(MatDialog);
|
dialog = TestBed.inject(MatDialog);
|
||||||
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open dialog with parent node `id` as data property', fakeAsync(() => {
|
it('should open dialog with parent node `id` as data property', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'parent-node-id' } }] }
|
list: { entries: [{ entry: { id: 'parent-node-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
@ -75,7 +72,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should remove parents path for templates breadcrumb', fakeAsync(() => {
|
it('should remove parents path for templates breadcrumb', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: {
|
list: {
|
||||||
entries: [
|
entries: [
|
||||||
@ -115,7 +112,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should set template folder path as root for breadcrumb', fakeAsync(() => {
|
it('should set template folder path as root for breadcrumb', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: {
|
list: {
|
||||||
entries: [
|
entries: [
|
||||||
@ -156,7 +153,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should raise an error when getNodeInfo fails', fakeAsync(() => {
|
it('should raise an error when getNodeInfo fails', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.reject({
|
Promise.reject({
|
||||||
message: `{ "error": { "statusCode": 404 } } `
|
message: `{ "error": { "statusCode": 404 } } `
|
||||||
})
|
})
|
||||||
@ -170,7 +167,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return true if row is not a `link` nodeType', fakeAsync(() => {
|
it('should return true if row is not a `link` nodeType', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: {
|
list: {
|
||||||
entries: [
|
entries: [
|
||||||
@ -200,7 +197,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return false if row is a `filelink` nodeType', fakeAsync(() => {
|
it('should return false if row is a `filelink` nodeType', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: {
|
list: {
|
||||||
entries: [
|
entries: [
|
||||||
@ -230,7 +227,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return false if row is a `folderlink` nodeType', fakeAsync(() => {
|
it('should return false if row is a `folderlink` nodeType', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: {
|
list: {
|
||||||
entries: [
|
entries: [
|
||||||
@ -261,7 +258,7 @@ describe('NodeTemplateService', () => {
|
|||||||
|
|
||||||
describe('File templates', () => {
|
describe('File templates', () => {
|
||||||
it('should return false if selected node is not a file', fakeAsync(() => {
|
it('should return false if selected node is not a file', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
@ -282,7 +279,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return true if selected node is a template file', fakeAsync(() => {
|
it('should return true if selected node is a template file', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
@ -303,7 +300,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should set dialog title for file templates', fakeAsync(() => {
|
it('should set dialog title for file templates', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
@ -321,7 +318,7 @@ describe('NodeTemplateService', () => {
|
|||||||
|
|
||||||
describe('Folder templates', () => {
|
describe('Folder templates', () => {
|
||||||
it('should return false if selected node is not a folder', fakeAsync(() => {
|
it('should return false if selected node is not a folder', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
@ -342,7 +339,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return false if current node is the parent folder', fakeAsync(() => {
|
it('should return false if current node is the parent folder', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
@ -363,7 +360,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return true if selected node is a folder template', fakeAsync(() => {
|
it('should return true if selected node is a folder template', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: {
|
list: {
|
||||||
entries: [{ entry: { id: 'templates-folder-id', path: { elements: [] } } }]
|
entries: [{ entry: { id: 'templates-folder-id', path: { elements: [] } } }]
|
||||||
@ -386,7 +383,7 @@ describe('NodeTemplateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should set dialog title for folder templates', fakeAsync(() => {
|
it('should set dialog title for folder templates', fakeAsync(() => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(
|
spyOn(nodeTemplateService['searchApi'], 'search').and.returnValue(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
list: { entries: [{ entry: { id: 'templates-folder-id' } }] }
|
||||||
} as ResultSetPaging)
|
} as ResultSetPaging)
|
||||||
|
@ -27,7 +27,7 @@ import { Injectable } from '@angular/core';
|
|||||||
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 { Subject, from, of } from 'rxjs';
|
import { Subject, from, of } from 'rxjs';
|
||||||
import { Node, MinimalNode, MinimalNodeEntryEntity, ResultNode, PathElement } from '@alfresco/js-api';
|
import { Node, MinimalNode, MinimalNodeEntryEntity, ResultNode, PathElement, SearchApi } from '@alfresco/js-api';
|
||||||
import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core';
|
||||||
import { switchMap, catchError } from 'rxjs/operators';
|
import { switchMap, catchError } from 'rxjs/operators';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
@ -45,13 +45,16 @@ export interface TemplateDialogConfig {
|
|||||||
export class NodeTemplateService {
|
export class NodeTemplateService {
|
||||||
private currentTemplateConfig: TemplateDialogConfig = null;
|
private currentTemplateConfig: TemplateDialogConfig = null;
|
||||||
private rootNode: ResultNode;
|
private rootNode: ResultNode;
|
||||||
|
private searchApi: SearchApi;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<AppStore>,
|
private store: Store<AppStore>,
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
private alfrescoApiService: AlfrescoApiService,
|
||||||
private translation: TranslationService,
|
private translation: TranslationService,
|
||||||
public dialog: MatDialog
|
public dialog: MatDialog
|
||||||
) {}
|
) {
|
||||||
|
this.searchApi = new SearchApi(this.alfrescoApiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
selectTemplateDialog(config: TemplateDialogConfig): Subject<Node[]> {
|
selectTemplateDialog(config: TemplateDialogConfig): Subject<Node[]> {
|
||||||
this.currentTemplateConfig = config;
|
this.currentTemplateConfig = config;
|
||||||
@ -84,7 +87,7 @@ export class NodeTemplateService {
|
|||||||
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
||||||
};
|
};
|
||||||
|
|
||||||
from(this.alfrescoApiService.searchApi.search(query))
|
from(this.searchApi.search(query))
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((response) => {
|
switchMap((response) => {
|
||||||
const entry = response.list.entries[0].entry;
|
const entry = response.list.entries[0].entry;
|
||||||
|
@ -44,6 +44,7 @@ import {
|
|||||||
ContextMenuEffects
|
ContextMenuEffects
|
||||||
} from './effects';
|
} from './effects';
|
||||||
import { INITIAL_STATE } from './initial-state';
|
import { INITIAL_STATE } from './initial-state';
|
||||||
|
import { provideBootstrapEffects } from './bootstrap-effect';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@ -62,7 +63,11 @@ import { INITIAL_STATE } from './initial-state';
|
|||||||
stateKey: 'router'
|
stateKey: 'router'
|
||||||
}),
|
}),
|
||||||
SharedStoreModule,
|
SharedStoreModule,
|
||||||
EffectsModule.forRoot([
|
EffectsModule.forRoot([]),
|
||||||
|
!environment.production ? StoreDevtoolsModule.instrument({ maxAge: 25 }) : []
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
provideBootstrapEffects([
|
||||||
AppEffects,
|
AppEffects,
|
||||||
NodeEffects,
|
NodeEffects,
|
||||||
DownloadEffects,
|
DownloadEffects,
|
||||||
@ -73,8 +78,7 @@ import { INITIAL_STATE } from './initial-state';
|
|||||||
FavoriteEffects,
|
FavoriteEffects,
|
||||||
TemplateEffects,
|
TemplateEffects,
|
||||||
ContextMenuEffects
|
ContextMenuEffects
|
||||||
]),
|
])
|
||||||
!environment.production ? StoreDevtoolsModule.instrument({ maxAge: 25 }) : []
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppStoreModule {}
|
export class AppStoreModule {}
|
||||||
|
52
src/app/store/bootstrap-effect.ts
Normal file
52
src/app/store/bootstrap-effect.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { APP_BOOTSTRAP_LISTENER, InjectionToken, Inject, Type } from '@angular/core';
|
||||||
|
import { EffectSources } from '@ngrx/effects';
|
||||||
|
|
||||||
|
export const BOOTSTRAP_EFFECTS = new InjectionToken('Bootstrap Effects');
|
||||||
|
|
||||||
|
export function bootstrapEffects(effects: Type<any>[], sources: EffectSources) {
|
||||||
|
return () => {
|
||||||
|
effects.forEach((effect) => sources.addEffects(effect));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createInstances(...instances: any[]) {
|
||||||
|
return instances;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function provideBootstrapEffects(effects: Type<any>[]) {
|
||||||
|
return [
|
||||||
|
effects,
|
||||||
|
{ provide: BOOTSTRAP_EFFECTS, deps: effects, useFactory: createInstances },
|
||||||
|
{
|
||||||
|
provide: APP_BOOTSTRAP_LISTENER,
|
||||||
|
multi: true,
|
||||||
|
useFactory: bootstrapEffects,
|
||||||
|
deps: [[new Inject(BOOTSTRAP_EFFECTS)], EffectSources]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
@ -31,7 +31,6 @@ import { Store } from '@ngrx/store';
|
|||||||
import { CreateFromTemplate, CreateFromTemplateSuccess, FileFromTemplate, FolderFromTemplate, SnackbarErrorAction } from '@alfresco/aca-shared/store';
|
import { CreateFromTemplate, CreateFromTemplateSuccess, FileFromTemplate, FolderFromTemplate, SnackbarErrorAction } from '@alfresco/aca-shared/store';
|
||||||
import { NodeTemplateService } from '../../services/node-template.service';
|
import { NodeTemplateService } from '../../services/node-template.service';
|
||||||
import { of, Subject } from 'rxjs';
|
import { of, Subject } from 'rxjs';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
|
||||||
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';
|
||||||
@ -40,8 +39,8 @@ import { AppHookService } from '@alfresco/aca-shared';
|
|||||||
describe('TemplateEffects', () => {
|
describe('TemplateEffects', () => {
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
let nodeTemplateService: NodeTemplateService;
|
let nodeTemplateService: NodeTemplateService;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
|
||||||
let appHookService: AppHookService;
|
let appHookService: AppHookService;
|
||||||
|
let templateEffects: TemplateEffects;
|
||||||
let copyNodeSpy;
|
let copyNodeSpy;
|
||||||
let updateNodeSpy;
|
let updateNodeSpy;
|
||||||
let matDialog: MatDialog;
|
let matDialog: MatDialog;
|
||||||
@ -88,7 +87,7 @@ describe('TemplateEffects', () => {
|
|||||||
|
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
nodeTemplateService = TestBed.inject(NodeTemplateService);
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
templateEffects = TestBed.inject(TemplateEffects);
|
||||||
appHookService = TestBed.inject(AppHookService);
|
appHookService = TestBed.inject(AppHookService);
|
||||||
matDialog = TestBed.inject(MatDialog);
|
matDialog = TestBed.inject(MatDialog);
|
||||||
subject = new Subject<Node[]>();
|
subject = new Subject<Node[]>();
|
||||||
@ -98,8 +97,8 @@ describe('TemplateEffects', () => {
|
|||||||
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);
|
||||||
|
|
||||||
copyNodeSpy = spyOn(alfrescoApiService.getInstance().nodes, 'copyNode');
|
copyNodeSpy = spyOn(templateEffects['nodesApi'], 'copyNode');
|
||||||
updateNodeSpy = spyOn(alfrescoApiService.getInstance().nodes, 'updateNode');
|
updateNodeSpy = spyOn(templateEffects['nodesApi'], 'updateNode');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -41,11 +41,13 @@ import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-t
|
|||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { AppHookService } from '@alfresco/aca-shared';
|
import { AppHookService } from '@alfresco/aca-shared';
|
||||||
import { from, Observable, of } from 'rxjs';
|
import { from, Observable, of } from 'rxjs';
|
||||||
import { NodeEntry, NodeBodyUpdate, Node } 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';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TemplateEffects {
|
export class TemplateEffects {
|
||||||
|
private nodesApi: NodesApi;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private matDialog: MatDialog,
|
private matDialog: MatDialog,
|
||||||
private appHookService: AppHookService,
|
private appHookService: AppHookService,
|
||||||
@ -53,7 +55,9 @@ export class TemplateEffects {
|
|||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private nodeTemplateService: NodeTemplateService
|
private nodeTemplateService: NodeTemplateService
|
||||||
) {}
|
) {
|
||||||
|
this.nodesApi = new NodesApi(this.apiService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({ dispatch: false })
|
||||||
fileFromTemplate$ = this.actions$.pipe(
|
fileFromTemplate$ = this.actions$.pipe(
|
||||||
@ -115,7 +119,7 @@ export class TemplateEffects {
|
|||||||
|
|
||||||
private copyNode(source: Node, parentId: string): Observable<NodeEntry> {
|
private copyNode(source: Node, parentId: string): Observable<NodeEntry> {
|
||||||
return from(
|
return from(
|
||||||
this.apiService.getInstance().nodes.copyNode(source.id, {
|
this.nodesApi.copyNode(source.id, {
|
||||||
targetParentId: parentId,
|
targetParentId: parentId,
|
||||||
name: source.name
|
name: source.name
|
||||||
})
|
})
|
||||||
@ -135,7 +139,7 @@ export class TemplateEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateNode(node: NodeEntry, update: NodeBodyUpdate): Observable<NodeEntry> {
|
private updateNode(node: NodeEntry, update: NodeBodyUpdate): Observable<NodeEntry> {
|
||||||
return from(this.apiService.getInstance().nodes.updateNode(node.entry.id, update)).pipe(catchError(() => of(node)));
|
return from(this.nodesApi.updateNode(node.entry.id, update)).pipe(catchError(() => of(node)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: Error): Observable<null> {
|
private handleError(error: Error): Observable<null> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user