feat: simplify field preview logic in Settings (#5541)

Closes #5382

TODO:

- [x] Test all field previews in app
- [x] Fix tests
- [x] Fix JSON preview
This commit is contained in:
Thaïs
2024-05-24 18:06:57 +02:00
committed by GitHub
parent 1ae7fbe90d
commit c7d61e183a
33 changed files with 1184 additions and 510 deletions

View File

@ -1,4 +1,4 @@
import { id } from 'date-fns/locale';
import { CurrencyCode } from '@/object-record/record-field/types/CurrencyCode';
import {
FieldMetadataType,
ObjectEdge,
@ -3787,10 +3787,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isNullable: true,
createdAt: '2024-04-08T12:48:49.538Z',
updatedAt: '2024-04-08T12:48:49.538Z',
defaultValue: {
lastName: "''",
firstName: "''",
},
defaultValue: null,
relationDefinition: null,
fromRelationMetadata: null,
toRelationMetadata: null,
@ -3876,10 +3873,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isNullable: true,
createdAt: '2024-04-08T12:48:49.538Z',
updatedAt: '2024-04-08T12:48:49.538Z',
defaultValue: {
url: "''",
label: "''",
},
defaultValue: null,
relationDefinition: null,
fromRelationMetadata: null,
toRelationMetadata: null,
@ -10562,7 +10556,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
updatedAt: '2024-04-08T12:48:49.538Z',
defaultValue: {
amountMicros: null,
currencyCode: "''",
currencyCode: `'${CurrencyCode.USD}'`,
},
relationDefinition: null,
fromRelationMetadata: null,
@ -10822,10 +10816,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isNullable: true,
createdAt: '2024-04-08T12:48:49.538Z',
updatedAt: '2024-04-08T12:48:49.538Z',
defaultValue: {
url: "''",
label: "''",
},
defaultValue: null,
relationDefinition: null,
fromRelationMetadata: null,
toRelationMetadata: null,
@ -12259,7 +12250,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
nameSingular: 'company',
namePlural: 'companies',
isSystem: false,
isRemote: false,
isRemote: false,
},
},
},
@ -12345,7 +12336,7 @@ isRemote: false,
nameSingular: 'opportunity',
namePlural: 'opportunities',
isSystem: false,
isRemote: false,
isRemote: false,
},
},
},
@ -12408,7 +12399,7 @@ isRemote: false,
nameSingular: 'listing',
namePlural: 'listings',
isSystem: false,
isRemote: false,
isRemote: false,
},
},
},
@ -13027,7 +13018,7 @@ isRemote: false,
nameSingular: 'opportunity',
namePlural: 'opportunities',
isSystem: false,
isRemote: false,
isRemote: false,
},
},
},
@ -13218,7 +13209,7 @@ isRemote: false,
nameSingular: 'company',
namePlural: 'companies',
isSystem: false,
isRemote: false,
isRemote: false,
},
},
relationDefinition: {

View File

@ -1,6 +1,7 @@
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { mapPaginatedObjectMetadataItemsToObjectMetadataItems } from '@/object-metadata/utils/mapPaginatedObjectMetadataItemsToObjectMetadataItems';
import {
FieldMetadataType,
ObjectEdge,
ObjectMetadataItemsQuery,
} from '~/generated-metadata/graphql';
@ -237,6 +238,48 @@ const customObjectMetadataItemEdge: ObjectEdge = {
toRelationMetadata: null,
},
},
{
__typename: 'fieldEdge',
node: {
__typename: 'field',
id: 'e07fcc3f-beec-4d91-8488-9d1d2cfa5f99',
type: FieldMetadataType.Select,
name: 'priority',
label: 'Priority',
description: 'A custom Select example',
icon: 'IconWarning',
isCustom: true,
isActive: true,
isSystem: false,
options: [
{
id: '2b98dc02-0d99-4f3e-890e-e2e6b8f3196c',
value: 'LOW',
label: 'Low',
color: 'turquoise',
},
{
id: 'd925a8de-d8ec-4b59-a079-64f4012e3311',
value: 'MEDIUM',
label: 'Medium',
color: 'yellow',
},
{
id: '3',
value: 'HIGH',
label: 'High',
color: 'red',
},
],
isNullable: true,
createdAt: '2024-04-08T12:48:49.538Z',
updatedAt: '2024-04-08T12:48:49.538Z',
defaultValue: null,
relationDefinition: null,
fromRelationMetadata: null,
toRelationMetadata: null,
},
},
],
},
},