mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[MNT-25478] Expose list parents method in nodes api service (#11622)
* [MNT-25478] Expose list parents method in nodes api service * [MNT-25478] CR fixes
This commit is contained in:
@@ -68,4 +68,11 @@ describe('NodesApiService', () => {
|
||||
|
||||
expect(nodesApiService.nodesApi.getFolderSizeInfo).toHaveBeenCalledWith('fake-node-id', 'fake-job-id');
|
||||
});
|
||||
|
||||
it('should call listParents api with nodeId and optional params', async () => {
|
||||
spyOn(nodesApiService.nodesApi, 'listParents').and.returnValue(Promise.resolve({ list: { entries: [] } }));
|
||||
await firstValueFrom(nodesApiService.listParents('fake-node-id', { include: ['path'], where: 'isPrimary=true' }));
|
||||
|
||||
expect(nodesApiService.nodesApi.listParents).toHaveBeenCalledWith('fake-node-id', { include: ['path'], where: 'isPrimary=true' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,8 @@ import {
|
||||
NodesIncludeQuery,
|
||||
TrashcanApi,
|
||||
SizeDetailsEntry,
|
||||
JobIdBodyEntry
|
||||
JobIdBodyEntry,
|
||||
NodeAssociationPaging
|
||||
} from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { from, Observable, Subject, throwError } from 'rxjs';
|
||||
@@ -55,7 +56,10 @@ export class NodesApiService {
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private preferences: UserPreferencesService) {}
|
||||
constructor(
|
||||
private readonly apiService: AlfrescoApiService,
|
||||
private readonly preferences: UserPreferencesService
|
||||
) {}
|
||||
|
||||
private getEntryFromEntity(entity: NodeEntry): Node {
|
||||
return entity.entry;
|
||||
@@ -278,6 +282,24 @@ export class NodesApiService {
|
||||
return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists parents of a given node.
|
||||
*
|
||||
* @param nodeId Node ID
|
||||
* @param opts Optional parameters
|
||||
* @returns List of parent nodes
|
||||
*/
|
||||
listParents(
|
||||
nodeId: string,
|
||||
opts?: {
|
||||
where?: string;
|
||||
includeSource?: boolean;
|
||||
} & NodesIncludeQuery &
|
||||
ContentPagingQuery
|
||||
): Observable<NodeAssociationPaging> {
|
||||
return from(this.nodesApi.listParents(nodeId, opts));
|
||||
}
|
||||
|
||||
private randomNodeName(): string {
|
||||
return `node_${Date.now()}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user