Refactor read only object and fields (#13936)
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
-50
@@ -1,50 +0,0 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { isWorkflowRelatedObjectMetadata } from '@/object-metadata/utils/isWorkflowRelatedObjectMetadata';
|
||||
|
||||
describe('isWorkflowRelatedObjectMetadata', () => {
|
||||
it('should return true for Workflow object', () => {
|
||||
const result = isWorkflowRelatedObjectMetadata(
|
||||
CoreObjectNameSingular.Workflow,
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for WorkflowVersion object', () => {
|
||||
const result = isWorkflowRelatedObjectMetadata(
|
||||
CoreObjectNameSingular.WorkflowVersion,
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for WorkflowRun object', () => {
|
||||
const result = isWorkflowRelatedObjectMetadata(
|
||||
CoreObjectNameSingular.WorkflowRun,
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for non-workflow related objects', () => {
|
||||
const result = isWorkflowRelatedObjectMetadata(
|
||||
CoreObjectNameSingular.Company,
|
||||
);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for unknown object names', () => {
|
||||
const result = isWorkflowRelatedObjectMetadata('unknownObject');
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for Person object', () => {
|
||||
const result = isWorkflowRelatedObjectMetadata(
|
||||
CoreObjectNameSingular.Person,
|
||||
);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
+1
@@ -49,6 +49,7 @@ export const formatFieldMetadataItemAsFieldDefinition = ({
|
||||
settings: field.settings,
|
||||
isNullable: field.isNullable,
|
||||
isCustom: field.isCustom ?? false,
|
||||
isUIReadOnly: field.isUIReadOnly ?? false,
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { isWorkflowSubObjectMetadata } from '@/object-metadata/utils/isWorkflowSubObjectMetadata';
|
||||
|
||||
export const isObjectMetadataReadOnly = (
|
||||
objectMetadataItem: Pick<ObjectMetadataItem, 'isRemote' | 'nameSingular'>,
|
||||
) =>
|
||||
objectMetadataItem.isRemote ||
|
||||
isWorkflowSubObjectMetadata(objectMetadataItem.nameSingular);
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { isWorkflowSubObjectMetadata } from '@/object-metadata/utils/isWorkflowSubObjectMetadata';
|
||||
|
||||
export const isWorkflowRelatedObjectMetadata = (objectNameSingular: string) => {
|
||||
return (
|
||||
objectNameSingular === CoreObjectNameSingular.Workflow ||
|
||||
isWorkflowSubObjectMetadata(objectNameSingular)
|
||||
);
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
|
||||
export const isWorkflowSubObjectMetadata = (
|
||||
objectMetadataNameSingular?: string,
|
||||
) =>
|
||||
objectMetadataNameSingular === CoreObjectNameSingular.WorkflowVersion ||
|
||||
objectMetadataNameSingular === CoreObjectNameSingular.WorkflowRun;
|
||||
Reference in New Issue
Block a user