mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8055] Integrate endpoint for getting Legal Holds (#9771)
* ACS-8055 add listAssignedHolds API * ACS-8055 create legal-hold service * ACS-8055 add documentation * ACS-8055 fix imports * ACS-8055 clean up code * ACS-8055 fix interface typo * ACS-8055 add optional options and uodate nodes-api.service.md * ACS-8055 update interface * ACS-8055 add HoldPaging class and documentation * ACS-8055 add interface and fix test * ACS-8055 add documentation for legal hold service * ACS-8055 update legal-hold.service.md * ACS-8055 update legal-hold.service.md * ACS-8055 update readme file * ACS-8055 add translation --------- Co-authored-by: DaryaBalvanovich <darya.balvanovich1@hyland.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api';
|
||||
import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node, Hold, ContentPagingQuery, NodesIncludeQuery } from '@alfresco/js-api';
|
||||
import { Subject, from, Observable, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
@@ -239,4 +239,31 @@ export class NodesApiService {
|
||||
|
||||
return new NodeMetadata(metadata, nodeEntry.entry.nodeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of holds assigned to the node.
|
||||
*
|
||||
* @param nodeId ID of the target node
|
||||
* @param options Optional parameters supported by JS-API
|
||||
* @param options.includeSource Also include **source** (in addition to **entries**) with folder information on **nodeId**
|
||||
* @returns List of assigned holds Observable<Hold[]>
|
||||
*/
|
||||
getNodeAssignHolds(
|
||||
nodeId: string,
|
||||
options?: {
|
||||
includeSource?: boolean;
|
||||
} & NodesIncludeQuery &
|
||||
ContentPagingQuery
|
||||
): Observable<Hold[]> {
|
||||
const queryOptions = Object.assign({ where: `(assocType='rma:frozenContent')` }, options);
|
||||
|
||||
return from(this.nodesApi.listParents(nodeId, queryOptions)).pipe(
|
||||
map(({ list }) =>
|
||||
list.entries?.map(({ entry }) => ({
|
||||
id: entry.id,
|
||||
name: entry.name
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"COMMON": {
|
||||
"APPLY": "Apply",
|
||||
"CANCEL": "Cancel"
|
||||
"CANCEL": "Cancel",
|
||||
"NAME": "Name"
|
||||
},
|
||||
"ADF_VERSION_LIST": {
|
||||
"ACTIONS": {
|
||||
|
18
lib/content-services/src/lib/legal-hold/index.ts
Normal file
18
lib/content-services/src/lib/legal-hold/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './public-api';
|
18
lib/content-services/src/lib/legal-hold/public-api.ts
Normal file
18
lib/content-services/src/lib/legal-hold/public-api.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './services/legal-hold.service';
|
@@ -0,0 +1,53 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { ContentPagingQuery, Hold, LegalHoldApi } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LegalHoldService {
|
||||
private _legalHoldApi: LegalHoldApi;
|
||||
get legalHoldApi(): LegalHoldApi {
|
||||
this._legalHoldApi = this._legalHoldApi ?? new LegalHoldApi(this.apiService.getInstance());
|
||||
return this._legalHoldApi;
|
||||
}
|
||||
|
||||
constructor(private readonly apiService: AlfrescoApiService) {}
|
||||
|
||||
/**
|
||||
* Gets the list of holds.
|
||||
*
|
||||
* @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
|
||||
* @param options Optional parameters supported by JS-API
|
||||
* @returns List of holds Observable<Hold[]>
|
||||
*/
|
||||
getHolds(filePlanId: string, options?: ContentPagingQuery): Observable<Hold[]> {
|
||||
return from(this.legalHoldApi.getHolds(filePlanId, options)).pipe(
|
||||
map(({ list }) =>
|
||||
list.entries?.map(({ entry }) => ({
|
||||
id: entry.id,
|
||||
name: entry.name
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { LegalHoldService } from './legal-hold.service';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { Hold, HoldPaging } from '@alfresco/js-api';
|
||||
|
||||
describe('LegalHoldsService', () => {
|
||||
let service: LegalHoldService;
|
||||
let legalHolds: HoldPaging;
|
||||
let returnedHolds: Hold[];
|
||||
const mockId = 'mockId';
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule]
|
||||
});
|
||||
service = TestBed.inject(LegalHoldService);
|
||||
|
||||
legalHolds = {
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: mockId,
|
||||
name: 'some name',
|
||||
reason: 'some description'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
} as HoldPaging;
|
||||
|
||||
returnedHolds = [
|
||||
{
|
||||
id: mockId,
|
||||
name: 'some name',
|
||||
reason: 'some description',
|
||||
description: undefined
|
||||
}
|
||||
];
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('getHolds', () => {
|
||||
it('should return array of Hold interface', (done) => {
|
||||
spyOn(service.legalHoldApi, 'getHolds').and.returnValue(Promise.resolve(legalHolds));
|
||||
|
||||
service.getHolds(mockId).subscribe((holds) => {
|
||||
expect(holds).toEqual(returnedHolds);
|
||||
expect(service.legalHoldApi.getHolds).toHaveBeenCalledWith(mockId, {});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -43,6 +43,7 @@ export * from './lib/viewer/index';
|
||||
export * from './lib/security/index';
|
||||
export * from './lib/infinite-scroll-datasource';
|
||||
export * from './lib/prediction/index';
|
||||
export * from './lib/legal-hold/index';
|
||||
|
||||
export * from './lib/content.module';
|
||||
export * from './lib/material.module';
|
||||
|
Reference in New Issue
Block a user