mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-9765]: adds utility functions for rma content
This commit is contained in:
@@ -24,6 +24,15 @@
|
|||||||
|
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
const RMA_NODE_TYPES = {
|
||||||
|
hold: 'rma:hold',
|
||||||
|
holdContainer: 'rma:holdContainer',
|
||||||
|
transferContainer: 'rma:transferContainer',
|
||||||
|
unfiledRecordContainer: 'rma:unfiledRecordContainer'
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
type RmaNodeType = (typeof RMA_NODE_TYPES)[keyof typeof RMA_NODE_TYPES];
|
||||||
|
|
||||||
export function isLocked(node: { entry: Node }): boolean {
|
export function isLocked(node: { entry: Node }): boolean {
|
||||||
if (node?.entry) {
|
if (node?.entry) {
|
||||||
const { entry } = node;
|
const { entry } = node;
|
||||||
@@ -43,3 +52,22 @@ export function isLibrary(node: { entry: Node | any }): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasNodeType =
|
||||||
|
(type: RmaNodeType) =>
|
||||||
|
(node: Node): boolean =>
|
||||||
|
node.nodeType === type;
|
||||||
|
|
||||||
|
const isRmaHoldsContainer = hasNodeType(RMA_NODE_TYPES.holdContainer);
|
||||||
|
const isRmaHold = hasNodeType(RMA_NODE_TYPES.hold);
|
||||||
|
const isRmaTransferContainer = hasNodeType(RMA_NODE_TYPES.transferContainer);
|
||||||
|
const isRmaUnfiledRecordsContainer = hasNodeType(RMA_NODE_TYPES.unfiledRecordContainer);
|
||||||
|
|
||||||
|
export const isRmaSystemFolder = (node: Node): boolean =>
|
||||||
|
isRmaHoldsContainer(node) || isRmaTransferContainer(node) || isRmaUnfiledRecordsContainer(node);
|
||||||
|
|
||||||
|
export const isRmaRestrictedCreateFolder = (node: Node): boolean => isRmaHold(node) || isRmaTransferContainer(node) || isRmaHoldsContainer(node);
|
||||||
|
|
||||||
|
export const isRmaContent = (node: Node): boolean => {
|
||||||
|
return node.nodeType.startsWith('rma:');
|
||||||
|
};
|
||||||
|
|||||||
@@ -22,9 +22,12 @@
|
|||||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isLibrary, isLocked } from './node.utils';
|
import { isLibrary, isLocked, isRmaContent, isRmaSystemFolder } from './node.utils';
|
||||||
|
import { Node } from '@alfresco/js-api';
|
||||||
|
|
||||||
describe('NodeUtils', () => {
|
describe('NodeUtils', () => {
|
||||||
|
const prepareNode = (nodeType: string): Node => ({ nodeType }) as Node;
|
||||||
|
|
||||||
describe('isLocked', () => {
|
describe('isLocked', () => {
|
||||||
it('should return [false] if entry is not defined', () => {
|
it('should return [false] if entry is not defined', () => {
|
||||||
expect(isLocked(null)).toBeFalse();
|
expect(isLocked(null)).toBeFalse();
|
||||||
@@ -111,4 +114,44 @@ describe('NodeUtils', () => {
|
|||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isRmaSystemFolder', () => {
|
||||||
|
it('should return [true] for rma:holdContainer', () => {
|
||||||
|
expect(isRmaSystemFolder(prepareNode('rma:holdContainer'))).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return [true] for rma:transferContainer', () => {
|
||||||
|
expect(isRmaSystemFolder(prepareNode('rma:transferContainer'))).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return [true] for rma:unfiledRecordContainer', () => {
|
||||||
|
expect(isRmaSystemFolder(prepareNode('rma:unfiledRecordContainer'))).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return [false] for non RMA system folder node type', () => {
|
||||||
|
expect(isRmaSystemFolder(prepareNode('rma:hold'))).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return [false] for unknown node type', () => {
|
||||||
|
expect(isRmaSystemFolder(prepareNode('unknown'))).toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isRmaContent', () => {
|
||||||
|
it('should return [true] for node type starting with rma:', () => {
|
||||||
|
expect(isRmaContent(prepareNode('rma:hold'))).toBeTrue();
|
||||||
|
expect(isRmaContent(prepareNode('rma:holdContainer'))).toBeTrue();
|
||||||
|
expect(isRmaContent(prepareNode('rma:transferContainer'))).toBeTrue();
|
||||||
|
expect(isRmaContent(prepareNode('rma:unfiledRecordContainer'))).toBeTrue();
|
||||||
|
expect(isRmaContent(prepareNode('rma:whatever'))).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return [false] for node type not starting with rma:', () => {
|
||||||
|
expect(isRmaContent(prepareNode('cm:content'))).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false when nodeType is missing', () => {
|
||||||
|
expect(isRmaContent({} as any)).toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user