Redesign Object/Field tables (#16844)
Redesign the data model pages for more clarity / better distinction between fields and relations
This commit is contained in:
+19
-8
@@ -12,13 +12,12 @@ describe('isObjectMetadataSettingsReadOnly', () => {
|
||||
isUIReadOnly: false,
|
||||
isRemote: false,
|
||||
},
|
||||
workspaceCustomApplicationId: 'workspaceApplicationId',
|
||||
});
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true if object is managed by application', () => {
|
||||
it('should return true if object is remote', () => {
|
||||
const result = isObjectMetadataSettingsReadOnly({
|
||||
objectPermissions: {
|
||||
canUpdateObjectRecords: true,
|
||||
@@ -26,24 +25,36 @@ describe('isObjectMetadataSettingsReadOnly', () => {
|
||||
restrictedFields: {},
|
||||
},
|
||||
objectMetadataItem: {
|
||||
applicationId: 'applicationId',
|
||||
isUIReadOnly: false,
|
||||
isRemote: false,
|
||||
isRemote: true,
|
||||
},
|
||||
workspaceCustomApplicationId: null,
|
||||
});
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if object is owned by workspace custom application', () => {
|
||||
it('should return true if object is UI read only', () => {
|
||||
const result = isObjectMetadataSettingsReadOnly({
|
||||
objectMetadataItem: {
|
||||
isUIReadOnly: true,
|
||||
isRemote: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for standard/third-party objects (they are editable via standardOverrides)', () => {
|
||||
const result = isObjectMetadataSettingsReadOnly({
|
||||
objectPermissions: {
|
||||
canUpdateObjectRecords: true,
|
||||
objectMetadataId: '123',
|
||||
restrictedFields: {},
|
||||
},
|
||||
objectMetadataItem: {
|
||||
isUIReadOnly: false,
|
||||
isRemote: false,
|
||||
applicationId: 'workspaceApplicationId',
|
||||
},
|
||||
workspaceCustomApplicationId: 'workspaceApplicationId',
|
||||
});
|
||||
|
||||
expect(result).toBe(false);
|
||||
|
||||
+6
-17
@@ -1,28 +1,17 @@
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { isObjectMetadataReadOnly } from '@/object-record/read-only/utils/isObjectMetadataReadOnly';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { type ObjectPermission } from '~/generated/graphql';
|
||||
|
||||
type IsObjectMetadataReadOnlyParams = {
|
||||
type IsObjectMetadataSettingsReadOnlyParams = {
|
||||
objectPermissions?: ObjectPermission;
|
||||
objectMetadataItem?: Pick<
|
||||
ObjectMetadataItem,
|
||||
'isUIReadOnly' | 'isRemote' | 'applicationId'
|
||||
>;
|
||||
workspaceCustomApplicationId: string | null;
|
||||
objectMetadataItem?: Pick<ObjectMetadataItem, 'isUIReadOnly' | 'isRemote'>;
|
||||
};
|
||||
|
||||
// Returns true only for remote or UI read-only objects
|
||||
// Standard and third-party app objects are editable (label/icon/description via standardOverrides)
|
||||
export const isObjectMetadataSettingsReadOnly = ({
|
||||
objectPermissions,
|
||||
objectMetadataItem,
|
||||
workspaceCustomApplicationId,
|
||||
}: IsObjectMetadataReadOnlyParams) => {
|
||||
return (
|
||||
isObjectMetadataReadOnly({ objectPermissions, objectMetadataItem }) ||
|
||||
(isDefined(objectMetadataItem?.applicationId)
|
||||
? isDefined(workspaceCustomApplicationId)
|
||||
? objectMetadataItem.applicationId !== workspaceCustomApplicationId
|
||||
: true
|
||||
: false)
|
||||
);
|
||||
}: IsObjectMetadataSettingsReadOnlyParams) => {
|
||||
return isObjectMetadataReadOnly({ objectPermissions, objectMetadataItem });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user