Deprecate old relations completely (#12482)
# What Fully deprecate old relations because we have one bug tied to it and it make the codebase complex # How I've made this PR: 1. remove metadata datasource (we only keep 'core') => this was causing extra complexity in the refactor + flaky reset 2. merge dev and demo datasets => as I needed to update the tests which is very painful, I don't want to do it twice 3. remove all code tied to RELATION_METADATA / relation-metadata.resolver, or anything tied to the old relation system 4. Remove ONE_TO_ONE and MANY_TO_MANY that are not supported 5. fix impacts on the different areas : see functional testing below # Functional testing ## Functional testing from the front-end: 1. Database Reset ✅ 2. Sign In ✅ 3. Workspace sign-up ✅ 5. Browsing table / kanban / show ✅ 6. Assigning a record in a one to many / in a many to one ✅ 7. Deleting a record involved in a relation ✅ => broken but not tied to this PR 8. "Add new" from relation picker ✅ => broken but not tied to this PR 9. Creating a Task / Note, Updating a Task / Note relations, Deleting a Task / Note (from table, show page, right drawer) ✅ => broken but not tied to this PR 10. creating a relation from settings (custom / standard x oneToMany / manyToOne) ✅ 11. updating a relation from settings should not be possible ✅ 12. deleting a relation from settings (custom / standard x oneToMany / manyToOne) ✅ 13. Make sure timeline activity still work (relation were involved there), espacially with Task / Note => to be double checked ✅ => Cannot convert undefined or null to object 14. Workspace deletion / User deletion ✅ 15. CSV Import should keep working ✅ 16. Permissions: I have tested without permissions V2 as it's still hard to test v2 work and it's not in prod yet ✅ 17. Workflows global test ✅ ## From the API: 1. Review open-api documentation (REST) ✅ 2. Make sure REST Api are still able to fetch relations ==> won't do, we have a coupling Get/Update/Create there, this requires refactoring 3. Make sure REST Api is still able to update / remove relation => won't do same ## Automated tests 1. lint + typescript ✅ 2. front unit tests: ✅ 3. server unit tests 2 ✅ 4. front stories: ✅ 5. server integration: ✅ 6. chromatic check : expected 0 7. e2e check : expected no more that current failures ## Remove // Todos 1. All are captured by functional tests above, nothing additional to do ## (Un)related regressions 1. Table loading state is not working anymore, we see the empty state before table content 2. Filtering by Creator Tim Ap return empty results 3. Not possible to add Tasks / Notes / Files from show page # Result ## New seeds that can be easily extended <img width="1920" alt="image" src="https://github.com/user-attachments/assets/d290d130-2a5f-44e6-b419-7e42a89eec4b" /> ## -5k lines of code ## No more 'metadata' dataSource (we only have 'core) ## No more relationMetadata (I haven't drop the table yet it's not referenced in the code anymore) ## We are ready to fix the 6 months lag between current API results and our mocked tests ## No more bug on relation creation / deletion --------- Co-authored-by: Weiko <corentin@twenty.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -48,6 +48,7 @@ const mocks: MockedResponse[] = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
type
|
||||
|
||||
@ -43,6 +43,7 @@ const mocks: MockedResponse[] = [
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
position
|
||||
timeFormat
|
||||
timeZone
|
||||
updatedAt
|
||||
@ -65,6 +66,7 @@ const mocks: MockedResponse[] = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
type
|
||||
@ -73,6 +75,10 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
}
|
||||
body
|
||||
bodyV2 {
|
||||
blocknote
|
||||
markdown
|
||||
}
|
||||
createdAt
|
||||
createdBy {
|
||||
source
|
||||
@ -97,6 +103,7 @@ const mocks: MockedResponse[] = [
|
||||
personId
|
||||
petId
|
||||
position
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -121,6 +128,7 @@ const mocks: MockedResponse[] = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -145,6 +153,7 @@ const mocks: MockedResponse[] = [
|
||||
personId
|
||||
petId
|
||||
properties
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
|
||||
@ -9,9 +9,9 @@ import { RecordGqlConnection } from '@/object-record/graphql/types/RecordGqlConn
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { ApolloCache } from '@apollo/client';
|
||||
import { isArray } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
type triggerUpdateRelationsOptimisticEffectArgs = {
|
||||
cache: ApolloCache<unknown>;
|
||||
@ -48,14 +48,13 @@ export const triggerUpdateRelationsOptimisticEffect = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const relationDefinition =
|
||||
fieldMetadataItemOnSourceRecord.relationDefinition;
|
||||
const relation = fieldMetadataItemOnSourceRecord.relation;
|
||||
|
||||
if (!relationDefinition) {
|
||||
if (!relation) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { targetObjectMetadata, targetFieldMetadata } = relationDefinition;
|
||||
const { targetObjectMetadata, targetFieldMetadata } = relation;
|
||||
|
||||
const fullTargetObjectMetadataItem = objectMetadataItems.find(
|
||||
({ nameSingular }) =>
|
||||
@ -94,7 +93,7 @@ export const triggerUpdateRelationsOptimisticEffect = ({
|
||||
return [];
|
||||
}
|
||||
|
||||
if (isObjectRecordConnection(relationDefinition, value)) {
|
||||
if (isObjectRecordConnection(relation, value)) {
|
||||
return value.edges.map(({ node }) => node);
|
||||
}
|
||||
|
||||
|
||||
@ -123,6 +123,7 @@ const mocks = [
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
position
|
||||
timeFormat
|
||||
timeZone
|
||||
updatedAt
|
||||
@ -284,6 +285,7 @@ const mocks = [
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
position
|
||||
timeFormat
|
||||
timeZone
|
||||
updatedAt
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -69,8 +69,7 @@ export const sortFavorites = (
|
||||
const relationObject = favorite[relationField.name];
|
||||
|
||||
const objectNameSingular =
|
||||
relationField.relationDefinition?.targetObjectMetadata
|
||||
.nameSingular ?? '';
|
||||
relationField.relation?.targetObjectMetadata.nameSingular ?? '';
|
||||
|
||||
const objectRecordIdentifier =
|
||||
getObjectRecordIdentifierByNameSingular(
|
||||
|
||||
@ -45,23 +45,6 @@ export const CREATE_ONE_FIELD_METADATA_ITEM = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const CREATE_ONE_RELATION_METADATA_ITEM = gql`
|
||||
mutation CreateOneRelationMetadataItem(
|
||||
$input: CreateOneRelationMetadataInput!
|
||||
) {
|
||||
createOneRelationMetadata(input: $input) {
|
||||
id
|
||||
relationType
|
||||
fromObjectMetadataId
|
||||
toObjectMetadataId
|
||||
fromFieldMetadataId
|
||||
toFieldMetadataId
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_ONE_FIELD_METADATA_ITEM = gql`
|
||||
mutation UpdateOneFieldMetadataItem(
|
||||
$idToUpdate: UUID!
|
||||
@ -152,11 +135,3 @@ export const DELETE_ONE_FIELD_METADATA_ITEM = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_ONE_RELATION_METADATA_ITEM = gql`
|
||||
mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) {
|
||||
deleteOneRelation(input: { id: $idToDelete }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@ -67,23 +67,22 @@ export const FIND_MANY_OBJECT_METADATA_ITEMS = gql`
|
||||
options
|
||||
settings
|
||||
isLabelSyncedWithName
|
||||
relationDefinition {
|
||||
relationId
|
||||
direction
|
||||
relation {
|
||||
type
|
||||
sourceObjectMetadata {
|
||||
id
|
||||
nameSingular
|
||||
namePlural
|
||||
}
|
||||
targetObjectMetadata {
|
||||
id
|
||||
nameSingular
|
||||
namePlural
|
||||
}
|
||||
sourceFieldMetadata {
|
||||
id
|
||||
name
|
||||
}
|
||||
targetObjectMetadata {
|
||||
id
|
||||
nameSingular
|
||||
namePlural
|
||||
}
|
||||
targetFieldMetadata {
|
||||
id
|
||||
name
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const query = gql`
|
||||
mutation CreateOneRelationMetadataItem(
|
||||
$input: CreateOneRelationMetadataInput!
|
||||
) {
|
||||
createOneRelationMetadata(input: $input) {
|
||||
id
|
||||
relationType
|
||||
fromObjectMetadataId
|
||||
toObjectMetadataId
|
||||
fromFieldMetadataId
|
||||
toFieldMetadataId
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const variables = {
|
||||
input: {
|
||||
relationMetadata: {
|
||||
fromDescription: null,
|
||||
fromIcon: undefined,
|
||||
fromLabel: 'label',
|
||||
fromName: 'name',
|
||||
fromObjectMetadataId: 'objectMetadataId',
|
||||
relationType: 'ONE_TO_ONE',
|
||||
toDescription: null,
|
||||
toIcon: undefined,
|
||||
toLabel: 'Another label',
|
||||
toName: 'anotherName',
|
||||
toObjectMetadataId: 'objectMetadataId1',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const responseData = {
|
||||
id: '',
|
||||
relationType: 'ONE_TO_ONE',
|
||||
fromObjectMetadataId: 'objectMetadataId',
|
||||
toObjectMetadataId: 'objectMetadataId1',
|
||||
fromFieldMetadataId: '',
|
||||
toFieldMetadataId: '',
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
};
|
||||
@ -1,15 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const query = gql`
|
||||
mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) {
|
||||
deleteOneRelation(input: { id: $idToDelete }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const variables = { idToDelete: 'idToDelete' };
|
||||
|
||||
export const responseData = {
|
||||
id: 'idToDelete',
|
||||
};
|
||||
@ -4,7 +4,6 @@ import { FieldMetadataType, PermissionsOnAllObjectRecords } from '~/generated/gr
|
||||
export const FIELD_METADATA_ID = '2c43466a-fe9e-4005-8d08-c5836067aa6c';
|
||||
export const FIELD_RELATION_METADATA_ID =
|
||||
'4da0302d-358a-45cd-9973-9f92723ed3c1';
|
||||
export const RELATION_METADATA_ID = 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6';
|
||||
|
||||
export const queries = {
|
||||
deleteMetadataField: gql`
|
||||
@ -67,13 +66,6 @@ export const queries = {
|
||||
}
|
||||
}
|
||||
`,
|
||||
deleteMetadataFieldRelation: gql`
|
||||
mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) {
|
||||
deleteOneRelation(input: { id: $idToDelete }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
activateMetadataField: gql`
|
||||
mutation UpdateOneFieldMetadataItem(
|
||||
$idToUpdate: UUID!
|
||||
@ -216,7 +208,7 @@ export const objectMetadataId = '25611fce-6637-4089-b0ca-91afeec95784';
|
||||
|
||||
export const variables = {
|
||||
deleteMetadataField: { idToDelete: FIELD_METADATA_ID },
|
||||
deleteMetadataFieldRelation: { idToDelete: RELATION_METADATA_ID },
|
||||
deleteMetadataFieldRelation: { idToDelete: FIELD_RELATION_METADATA_ID },
|
||||
activateMetadataField: {
|
||||
idToUpdate: FIELD_METADATA_ID,
|
||||
updatePayload: { isActive: true },
|
||||
|
||||
@ -69,6 +69,6 @@ describe('useColumnDefinitionsFromFieldMetadata', () => {
|
||||
|
||||
const { columnDefinitions } = result.current;
|
||||
|
||||
expect(columnDefinitions.length).toBe(22);
|
||||
expect(columnDefinitions.length).toBe(21);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { ReactNode, act } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useCreateOneRelationMetadataItem } from '@/object-metadata/hooks/useCreateOneRelationMetadataItem';
|
||||
import { RelationDefinitionType } from '~/generated/graphql';
|
||||
|
||||
import {
|
||||
query,
|
||||
responseData,
|
||||
variables,
|
||||
} from '../__mocks__/useCreateOneRelationMetadataItem';
|
||||
|
||||
import {
|
||||
query as findManyObjectMetadataItemsQuery,
|
||||
responseData as findManyObjectMetadataItemsResponseData,
|
||||
} from '../__mocks__/useFindManyObjectMetadataItems';
|
||||
|
||||
const mocks = [
|
||||
{
|
||||
request: {
|
||||
query,
|
||||
variables,
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
data: {
|
||||
createOneRelation: responseData,
|
||||
},
|
||||
})),
|
||||
},
|
||||
{
|
||||
request: {
|
||||
query: findManyObjectMetadataItemsQuery,
|
||||
variables: {},
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
data: findManyObjectMetadataItemsResponseData,
|
||||
})),
|
||||
},
|
||||
];
|
||||
|
||||
const Wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<RecoilRoot>
|
||||
<MockedProvider mocks={mocks} addTypename={false}>
|
||||
{children}
|
||||
</MockedProvider>
|
||||
</RecoilRoot>
|
||||
);
|
||||
|
||||
describe('useCreateOneRelationMetadataItem', () => {
|
||||
it('should work as expected', async () => {
|
||||
const { result } = renderHook(() => useCreateOneRelationMetadataItem(), {
|
||||
wrapper: Wrapper,
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
const res = await result.current.createOneRelationMetadataItem({
|
||||
relationType: RelationDefinitionType.ONE_TO_ONE,
|
||||
field: {
|
||||
label: 'label',
|
||||
name: 'name',
|
||||
},
|
||||
objectMetadataId: 'objectMetadataId',
|
||||
connect: {
|
||||
field: {
|
||||
label: 'Another label',
|
||||
name: 'anotherName',
|
||||
},
|
||||
objectMetadataId: 'objectMetadataId1',
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.data).toEqual({ createOneRelation: responseData });
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,63 +0,0 @@
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { ReactNode } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useDeleteOneRelationMetadataItem } from '@/object-metadata/hooks/useDeleteOneRelationMetadataItem';
|
||||
|
||||
import {
|
||||
query,
|
||||
responseData,
|
||||
variables,
|
||||
} from '../__mocks__/useDeleteOneRelationMetadataItem';
|
||||
|
||||
import {
|
||||
query as findManyObjectMetadataItemsQuery,
|
||||
responseData as findManyObjectMetadataItemsResponseData,
|
||||
} from '../__mocks__/useFindManyObjectMetadataItems';
|
||||
|
||||
const mocks = [
|
||||
{
|
||||
request: {
|
||||
query,
|
||||
variables,
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
data: {
|
||||
deleteOneRelation: responseData,
|
||||
},
|
||||
})),
|
||||
},
|
||||
{
|
||||
request: {
|
||||
query: findManyObjectMetadataItemsQuery,
|
||||
variables: {},
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
data: findManyObjectMetadataItemsResponseData,
|
||||
})),
|
||||
},
|
||||
];
|
||||
|
||||
const Wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<RecoilRoot>
|
||||
<MockedProvider mocks={mocks} addTypename={false}>
|
||||
{children}
|
||||
</MockedProvider>
|
||||
</RecoilRoot>
|
||||
);
|
||||
|
||||
describe('useDeleteOneRelationMetadataItem', () => {
|
||||
it('should work as expected', async () => {
|
||||
const { result } = renderHook(() => useDeleteOneRelationMetadataItem(), {
|
||||
wrapper: Wrapper,
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
const res =
|
||||
await result.current.deleteOneRelationMetadataItem('idToDelete');
|
||||
|
||||
expect(res.data).toEqual({ deleteOneRelation: responseData });
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -3,7 +3,7 @@ import { act } from 'react';
|
||||
|
||||
import { useFieldMetadataItem } from '@/object-metadata/hooks/useFieldMetadataItem';
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { FieldMetadataType, RelationDefinitionType } from '~/generated/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated/graphql';
|
||||
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import {
|
||||
@ -11,7 +11,6 @@ import {
|
||||
FIELD_RELATION_METADATA_ID,
|
||||
objectMetadataId,
|
||||
queries,
|
||||
RELATION_METADATA_ID,
|
||||
responseData,
|
||||
variables,
|
||||
} from '../__mocks__/useFieldMetadataItem';
|
||||
@ -49,9 +48,8 @@ const fieldRelationMetadataItem: FieldMetadataItem = {
|
||||
type: FieldMetadataType.RELATION,
|
||||
updatedAt: '',
|
||||
isLabelSyncedWithName: true,
|
||||
relationDefinition: {
|
||||
relationId: RELATION_METADATA_ID,
|
||||
direction: RelationDefinitionType.ONE_TO_MANY,
|
||||
relation: {
|
||||
type: RelationType.ONE_TO_MANY,
|
||||
sourceFieldMetadata: {
|
||||
id: 'e5903d91-9b10-4f3e-b761-35c36e93b7c1',
|
||||
name: 'sourceField',
|
||||
@ -112,12 +110,12 @@ const mocks = [
|
||||
},
|
||||
{
|
||||
request: {
|
||||
query: queries.deleteMetadataFieldRelation,
|
||||
query: queries.deleteMetadataField,
|
||||
variables: variables.deleteMetadataFieldRelation,
|
||||
},
|
||||
result: jest.fn(() => ({
|
||||
data: {
|
||||
deleteOneRelation: responseData.fieldRelation,
|
||||
deleteOneField: responseData.fieldRelation,
|
||||
},
|
||||
})),
|
||||
},
|
||||
@ -236,7 +234,7 @@ describe('useFieldMetadataItem', () => {
|
||||
);
|
||||
|
||||
expect(res.data).toEqual({
|
||||
deleteOneRelation: responseData.fieldRelation,
|
||||
deleteOneField: responseData.fieldRelation,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
import { useMutation } from '@apollo/client';
|
||||
|
||||
import {
|
||||
CreateOneRelationMetadataItemMutation,
|
||||
CreateOneRelationMetadataItemMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { CREATE_ONE_RELATION_METADATA_ITEM } from '../graphql/mutations';
|
||||
import {
|
||||
formatRelationMetadataInput,
|
||||
FormatRelationMetadataInputParams,
|
||||
} from '../utils/formatRelationMetadataInput';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useCreateOneRelationMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
CreateOneRelationMetadataItemMutation,
|
||||
CreateOneRelationMetadataItemMutationVariables
|
||||
>(CREATE_ONE_RELATION_METADATA_ITEM, {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
const createOneRelationMetadataItem = async (
|
||||
input: FormatRelationMetadataInputParams,
|
||||
) => {
|
||||
const result = await mutate({
|
||||
variables: {
|
||||
input: { relationMetadata: formatRelationMetadataInput(input) },
|
||||
},
|
||||
});
|
||||
|
||||
await refreshObjectMetadataItems();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return {
|
||||
createOneRelationMetadataItem,
|
||||
};
|
||||
};
|
||||
@ -1,42 +0,0 @@
|
||||
import { useMutation } from '@apollo/client';
|
||||
|
||||
import { DELETE_ONE_RELATION_METADATA_ITEM } from '@/object-metadata/graphql/mutations';
|
||||
import {
|
||||
DeleteOneRelationMetadataItemMutation,
|
||||
DeleteOneRelationMetadataItemMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useDeleteOneRelationMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
DeleteOneRelationMetadataItemMutation,
|
||||
DeleteOneRelationMetadataItemMutationVariables
|
||||
>(DELETE_ONE_RELATION_METADATA_ITEM, {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
const deleteOneRelationMetadataItem = async (
|
||||
idToDelete: DeleteOneRelationMetadataItemMutationVariables['idToDelete'],
|
||||
) => {
|
||||
const result = await mutate({
|
||||
variables: {
|
||||
idToDelete,
|
||||
},
|
||||
});
|
||||
|
||||
await refreshObjectMetadataItems();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return {
|
||||
deleteOneRelationMetadataItem,
|
||||
};
|
||||
};
|
||||
@ -1,10 +1,8 @@
|
||||
import { useDeleteOneRelationMetadataItem } from '@/object-metadata/hooks/useDeleteOneRelationMetadataItem';
|
||||
import { Field, FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { Field, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { FieldMetadataItem } from '../types/FieldMetadataItem';
|
||||
import { formatFieldMetadataItemInput } from '../utils/formatFieldMetadataItemInput';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useCreateOneFieldMetadataItem } from './useCreateOneFieldMetadataItem';
|
||||
import { useDeleteOneFieldMetadataItem } from './useDeleteOneFieldMetadataItem';
|
||||
import { useUpdateOneFieldMetadataItem } from './useUpdateOneFieldMetadataItem';
|
||||
@ -13,7 +11,6 @@ export const useFieldMetadataItem = () => {
|
||||
const { createOneFieldMetadataItem } = useCreateOneFieldMetadataItem();
|
||||
const { updateOneFieldMetadataItem } = useUpdateOneFieldMetadataItem();
|
||||
const { deleteOneFieldMetadataItem } = useDeleteOneFieldMetadataItem();
|
||||
const { deleteOneRelationMetadataItem } = useDeleteOneRelationMetadataItem();
|
||||
|
||||
const createMetadataField = (
|
||||
input: Pick<
|
||||
@ -29,6 +26,12 @@ export const useFieldMetadataItem = () => {
|
||||
| 'isLabelSyncedWithName'
|
||||
> & {
|
||||
objectMetadataId: string;
|
||||
relationCreationPayload?: {
|
||||
type: RelationType;
|
||||
targetObjectMetadataId: string;
|
||||
targetFieldLabel: string;
|
||||
targetFieldIcon: string;
|
||||
};
|
||||
},
|
||||
) => {
|
||||
const formattedInput = formatFieldMetadataItemInput(input);
|
||||
@ -40,6 +43,7 @@ export const useFieldMetadataItem = () => {
|
||||
label: formattedInput.label ?? '',
|
||||
name: formattedInput.name ?? '',
|
||||
isLabelSyncedWithName: formattedInput.isLabelSyncedWithName ?? true,
|
||||
relationCreationPayload: input.relationCreationPayload,
|
||||
});
|
||||
};
|
||||
|
||||
@ -64,12 +68,7 @@ export const useFieldMetadataItem = () => {
|
||||
});
|
||||
|
||||
const deleteMetadataField = (metadataField: FieldMetadataItem) => {
|
||||
return metadataField.type === FieldMetadataType.RELATION &&
|
||||
!isDefined(metadataField.settings?.relationType)
|
||||
? deleteOneRelationMetadataItem(
|
||||
metadataField.relationDefinition?.relationId,
|
||||
)
|
||||
: deleteOneFieldMetadataItem(metadataField.id);
|
||||
return deleteOneFieldMetadataItem(metadataField.id);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@ -11,21 +11,18 @@ export const useGetRelationMetadata = () =>
|
||||
({
|
||||
fieldMetadataItem,
|
||||
}: {
|
||||
fieldMetadataItem: Pick<
|
||||
FieldMetadataItem,
|
||||
'type' | 'relationDefinition'
|
||||
>;
|
||||
fieldMetadataItem: Pick<FieldMetadataItem, 'type' | 'relation'>;
|
||||
}) => {
|
||||
if (fieldMetadataItem.type !== FieldMetadataType.RELATION) return null;
|
||||
|
||||
const relationDefinition = fieldMetadataItem.relationDefinition;
|
||||
const relation = fieldMetadataItem.relation;
|
||||
|
||||
if (!relationDefinition) return null;
|
||||
if (!relation) return null;
|
||||
|
||||
const relationObjectMetadataItem = snapshot
|
||||
.getLoadable(
|
||||
objectMetadataItemFamilySelector({
|
||||
objectName: relationDefinition.targetObjectMetadata.nameSingular,
|
||||
objectName: relation.targetObjectMetadata.nameSingular,
|
||||
objectNameType: 'singular',
|
||||
}),
|
||||
)
|
||||
@ -35,7 +32,7 @@ export const useGetRelationMetadata = () =>
|
||||
|
||||
const relationFieldMetadataItem =
|
||||
relationObjectMetadataItem.fields.find(
|
||||
(field) => field.id === relationDefinition.targetFieldMetadata.id,
|
||||
(field) => field.id === relation.targetFieldMetadata.id,
|
||||
);
|
||||
|
||||
if (!relationFieldMetadataItem) return null;
|
||||
@ -43,7 +40,7 @@ export const useGetRelationMetadata = () =>
|
||||
return {
|
||||
relationFieldMetadataItem,
|
||||
relationObjectMetadataItem,
|
||||
relationType: relationDefinition.direction,
|
||||
relationType: relation.type,
|
||||
};
|
||||
},
|
||||
[],
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
import { FieldMetadataItemRelation } from '@/object-metadata/types/FieldMetadataItemRelation';
|
||||
import { FieldDateMetadataSettings } from '@/object-record/record-field/types/FieldMetadata';
|
||||
|
||||
import { ThemeColor } from 'twenty-ui/theme';
|
||||
import {
|
||||
Field,
|
||||
Object as MetadataObject,
|
||||
RelationDefinition,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { Field } from '~/generated-metadata/graphql';
|
||||
|
||||
export type FieldMetadataItemOption = {
|
||||
color: ThemeColor;
|
||||
@ -18,25 +14,12 @@ export type FieldMetadataItemOption = {
|
||||
|
||||
export type FieldMetadataItem = Omit<
|
||||
Field,
|
||||
'__typename' | 'defaultValue' | 'options' | 'relationDefinition'
|
||||
'__typename' | 'defaultValue' | 'options' | 'relation'
|
||||
> & {
|
||||
__typename?: string;
|
||||
defaultValue?: any;
|
||||
options?: FieldMetadataItemOption[] | null;
|
||||
relationDefinition?: {
|
||||
relationId: RelationDefinition['relationId'];
|
||||
direction: RelationDefinitionType;
|
||||
sourceFieldMetadata: Pick<Field, 'id' | 'name'>;
|
||||
sourceObjectMetadata: Pick<
|
||||
MetadataObject,
|
||||
'id' | 'nameSingular' | 'namePlural'
|
||||
>;
|
||||
targetFieldMetadata: Pick<Field, 'id' | 'name'>;
|
||||
targetObjectMetadata: Pick<
|
||||
MetadataObject,
|
||||
'id' | 'nameSingular' | 'namePlural'
|
||||
>;
|
||||
} | null;
|
||||
relation?: FieldMetadataItemRelation | null;
|
||||
settings?: FieldDateMetadataSettings;
|
||||
isLabelSyncedWithName?: boolean | null;
|
||||
};
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
|
||||
import { Field, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export type FieldMetadataItemRelation = {
|
||||
type: RelationType;
|
||||
sourceFieldMetadata: Pick<Field, 'id' | 'name'>;
|
||||
targetFieldMetadata: Pick<Field, 'id' | 'name'>;
|
||||
sourceObjectMetadata: Pick<
|
||||
ObjectMetadataItem,
|
||||
'id' | 'nameSingular' | 'namePlural'
|
||||
>;
|
||||
targetObjectMetadata: Pick<
|
||||
ObjectMetadataItem,
|
||||
'id' | 'nameSingular' | 'namePlural'
|
||||
>;
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
import { shouldFieldBeQueried } from '@/object-metadata/utils/shouldFieldBeQueried';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
describe('shouldFieldBeQueried', () => {
|
||||
describe('if recordGqlFields is absent, we query all except relations', () => {
|
||||
@ -11,20 +11,62 @@ describe('shouldFieldBeQueried', () => {
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('should not be queried if the field is a relation', () => {
|
||||
it('should not be queried if the field is a relation ONE_TO_MANY', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
gqlField: 'fieldName',
|
||||
fieldMetadata: { name: 'fieldName', type: FieldMetadataType.RELATION },
|
||||
fieldMetadata: {
|
||||
name: 'fieldName',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
it('should not be queried if the field is a relation MANY_TO_ONE', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
gqlField: 'fieldName',
|
||||
fieldMetadata: {
|
||||
name: 'fieldName',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
joinColumnName: 'fieldNameId',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
it('should be queried if the field is a relation MANY_TO_ONE and is the joinColumnName', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
gqlField: 'fieldNameId',
|
||||
fieldMetadata: {
|
||||
name: 'fieldNameId',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
joinColumnName: 'fieldNameId',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('if recordGqlFields is present, we respect it', () => {
|
||||
it('should be queried if true', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
gqlField: 'fieldName',
|
||||
fieldMetadata: { name: 'fieldName', type: FieldMetadataType.RELATION },
|
||||
fieldMetadata: {
|
||||
name: 'fieldName',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
recordGqlFields: { fieldName: true },
|
||||
});
|
||||
expect(res).toBe(true);
|
||||
@ -33,7 +75,13 @@ describe('shouldFieldBeQueried', () => {
|
||||
it('should be queried if object', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
recordGqlFields: { fieldName: { subFieldName: false } },
|
||||
fieldMetadata: { name: 'fieldName', type: FieldMetadataType.RELATION },
|
||||
fieldMetadata: {
|
||||
name: 'fieldName',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
gqlField: 'fieldName',
|
||||
});
|
||||
expect(res).toBe(true);
|
||||
@ -42,7 +90,13 @@ describe('shouldFieldBeQueried', () => {
|
||||
it('should not be queried if false', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
gqlField: 'fieldName',
|
||||
fieldMetadata: { name: 'fieldName', type: FieldMetadataType.RELATION },
|
||||
fieldMetadata: {
|
||||
name: 'fieldName',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
recordGqlFields: { fieldName: false },
|
||||
});
|
||||
expect(res).toBe(false);
|
||||
@ -51,7 +105,13 @@ describe('shouldFieldBeQueried', () => {
|
||||
it('should not be queried if absent', () => {
|
||||
const res = shouldFieldBeQueried({
|
||||
gqlField: 'fieldName',
|
||||
fieldMetadata: { name: 'fieldName', type: FieldMetadataType.RELATION },
|
||||
fieldMetadata: {
|
||||
name: 'fieldName',
|
||||
type: FieldMetadataType.RELATION,
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
recordGqlFields: { otherFieldName: false },
|
||||
});
|
||||
expect(res).toBe(false);
|
||||
|
||||
@ -18,16 +18,14 @@ export const formatFieldMetadataItemAsFieldDefinition = ({
|
||||
showLabel,
|
||||
labelWidth,
|
||||
}: FieldMetadataItemAsFieldDefinitionProps): FieldDefinition<FieldMetadata> => {
|
||||
const relationObjectMetadataItem =
|
||||
field.relationDefinition?.targetObjectMetadata;
|
||||
const relationObjectMetadataItem = field.relation?.targetObjectMetadata;
|
||||
|
||||
const relationFieldMetadataId =
|
||||
field.relationDefinition?.targetFieldMetadata.id;
|
||||
const relationFieldMetadataId = field.relation?.targetFieldMetadata.id;
|
||||
|
||||
const fieldDefintionMetadata = {
|
||||
fieldName: field.name,
|
||||
placeHolder: field.label,
|
||||
relationType: field.relationDefinition?.direction,
|
||||
relationType: field.relation?.type,
|
||||
relationFieldMetadataId,
|
||||
relationObjectMetadataNameSingular:
|
||||
relationObjectMetadataItem?.nameSingular ?? '',
|
||||
@ -35,8 +33,7 @@ export const formatFieldMetadataItemAsFieldDefinition = ({
|
||||
relationObjectMetadataItem?.namePlural ?? '',
|
||||
relationObjectMetadataId: relationObjectMetadataItem?.id ?? '',
|
||||
objectMetadataNameSingular: objectMetadataItem.nameSingular ?? '',
|
||||
targetFieldMetadataName:
|
||||
field.relationDefinition?.targetFieldMetadata?.name ?? '',
|
||||
targetFieldMetadataName: field.relation?.targetFieldMetadata?.name ?? '',
|
||||
options: field.options,
|
||||
settings: field.settings,
|
||||
isNullable: field.isNullable,
|
||||
|
||||
@ -8,7 +8,7 @@ export const getRelationObjectMetadataNameSingular = ({
|
||||
}: {
|
||||
field: ObjectMetadataItem['fields'][0];
|
||||
}): string | undefined => {
|
||||
return field.relationDefinition?.targetObjectMetadata.nameSingular;
|
||||
return field.relation?.targetObjectMetadata.nameSingular;
|
||||
};
|
||||
|
||||
export const getFilterTypeFromFieldType = (
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
import { RelationType } from '@/settings/data-model/types/RelationType';
|
||||
import {
|
||||
CreateRelationInput,
|
||||
Field,
|
||||
RelationDefinitionType,
|
||||
RelationMetadataType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { formatFieldMetadataItemInput } from './formatFieldMetadataItemInput';
|
||||
|
||||
export type FormatRelationMetadataInputParams = {
|
||||
relationType: RelationType;
|
||||
field: Pick<Field, 'label' | 'icon' | 'description' | 'name'>;
|
||||
objectMetadataId: string;
|
||||
connect: {
|
||||
field: Pick<Field, 'label' | 'icon' | 'name'>;
|
||||
objectMetadataId: string;
|
||||
};
|
||||
};
|
||||
|
||||
export const formatRelationMetadataInput = (
|
||||
input: FormatRelationMetadataInputParams,
|
||||
): CreateRelationInput => {
|
||||
// /!\ MANY_TO_ONE does not exist on backend.
|
||||
// => Transform into ONE_TO_MANY and invert "from" and "to" data.
|
||||
const isManyToOne = input.relationType === 'MANY_TO_ONE';
|
||||
const relationType = isManyToOne
|
||||
? RelationDefinitionType.ONE_TO_MANY
|
||||
: (input.relationType as RelationDefinitionType);
|
||||
const { field: fromField, objectMetadataId: fromObjectMetadataId } =
|
||||
isManyToOne ? input.connect : input;
|
||||
const { field: toField, objectMetadataId: toObjectMetadataId } = isManyToOne
|
||||
? input
|
||||
: input.connect;
|
||||
|
||||
const {
|
||||
description: fromDescription,
|
||||
icon: fromIcon,
|
||||
label: fromLabel = '',
|
||||
name: fromName = '',
|
||||
} = formatFieldMetadataItemInput(fromField);
|
||||
const {
|
||||
description: toDescription,
|
||||
icon: toIcon,
|
||||
label: toLabel = '',
|
||||
name: toName = '',
|
||||
} = formatFieldMetadataItemInput(toField);
|
||||
|
||||
return {
|
||||
fromDescription,
|
||||
fromIcon,
|
||||
fromLabel,
|
||||
fromName,
|
||||
fromObjectMetadataId,
|
||||
relationType: relationType as unknown as RelationMetadataType,
|
||||
toDescription,
|
||||
toIcon,
|
||||
toLabel,
|
||||
toName,
|
||||
toObjectMetadataId,
|
||||
};
|
||||
};
|
||||
@ -1,8 +1,5 @@
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const getFilterFilterableFieldMetadataItems = ({
|
||||
isJsonFilterEnabled,
|
||||
@ -15,9 +12,7 @@ export const getFilterFilterableFieldMetadataItems = ({
|
||||
|
||||
const isRelationFieldHandled = !(
|
||||
field.type === FieldMetadataType.RELATION &&
|
||||
field.relationDefinition?.direction !==
|
||||
RelationDefinitionType.MANY_TO_ONE &&
|
||||
field.relationDefinition?.direction !== RelationDefinitionType.ONE_TO_ONE
|
||||
field.relation?.type !== RelationType.MANY_TO_ONE
|
||||
);
|
||||
|
||||
const isFieldTypeFilterable = [
|
||||
|
||||
@ -3,7 +3,7 @@ import { isUndefined } from '@sniptt/guards';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
ObjectPermission,
|
||||
RelationDefinitionType,
|
||||
RelationType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
@ -18,13 +18,13 @@ type MapFieldMetadataToGraphQLQueryArgs = {
|
||||
gqlField: string;
|
||||
fieldMetadata: Pick<
|
||||
FieldMetadataItem,
|
||||
'name' | 'type' | 'relationDefinition' | 'settings'
|
||||
'name' | 'type' | 'relation' | 'settings'
|
||||
>;
|
||||
relationRecordGqlFields?: RecordGqlFields;
|
||||
computeReferences?: boolean;
|
||||
objectPermissionsByObjectMetadataId: Record<string, ObjectPermission>;
|
||||
};
|
||||
// TODO: change ObjectMetadataItems mock before refactoring with relationDefinition computed field
|
||||
// TODO: change ObjectMetadataItems mock before refactoring with relation computed field
|
||||
export const mapFieldMetadataToGraphQLQuery = ({
|
||||
objectMetadataItems,
|
||||
gqlField,
|
||||
@ -39,7 +39,7 @@ export const mapFieldMetadataToGraphQLQuery = ({
|
||||
|
||||
const objectPermission = getObjectPermissionsForObject(
|
||||
objectPermissionsByObjectMetadataId,
|
||||
fieldMetadata.relationDefinition?.targetObjectMetadata.id,
|
||||
fieldMetadata.relation?.targetObjectMetadata.id,
|
||||
);
|
||||
|
||||
if (fieldIsNonCompositeField) {
|
||||
@ -48,13 +48,12 @@ export const mapFieldMetadataToGraphQLQuery = ({
|
||||
|
||||
if (
|
||||
fieldType === FieldMetadataType.RELATION &&
|
||||
fieldMetadata.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
fieldMetadata.relation?.type === RelationType.MANY_TO_ONE
|
||||
) {
|
||||
const relationMetadataItem = objectMetadataItems.find(
|
||||
(objectMetadataItem) =>
|
||||
objectMetadataItem.id ===
|
||||
fieldMetadata.relationDefinition?.targetObjectMetadata.id,
|
||||
fieldMetadata.relation?.targetObjectMetadata.id,
|
||||
);
|
||||
|
||||
if (isUndefined(relationMetadataItem)) {
|
||||
@ -87,13 +86,12 @@ ${mapObjectMetadataToGraphQLQuery({
|
||||
|
||||
if (
|
||||
fieldType === FieldMetadataType.RELATION &&
|
||||
fieldMetadata.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
fieldMetadata.relation?.type === RelationType.ONE_TO_MANY
|
||||
) {
|
||||
const relationMetadataItem = objectMetadataItems.find(
|
||||
(objectMetadataItem) =>
|
||||
objectMetadataItem.id ===
|
||||
fieldMetadata.relationDefinition?.targetObjectMetadata.id,
|
||||
fieldMetadata.relation?.targetObjectMetadata.id,
|
||||
);
|
||||
|
||||
if (isUndefined(relationMetadataItem)) {
|
||||
|
||||
@ -3,6 +3,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { isFieldRelation } from '@/object-record/record-field/types/guards/isFieldRelation';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FieldMetadataItem } from '../types/FieldMetadataItem';
|
||||
|
||||
@ -12,13 +13,17 @@ export const shouldFieldBeQueried = ({
|
||||
recordGqlFields,
|
||||
}: {
|
||||
gqlField: string;
|
||||
fieldMetadata: Pick<FieldMetadataItem, 'name' | 'type'>;
|
||||
fieldMetadata: Pick<FieldMetadataItem, 'name' | 'type' | 'settings'>;
|
||||
objectRecord?: ObjectRecord;
|
||||
recordGqlFields?: RecordGqlOperationGqlRecordFields;
|
||||
}): any => {
|
||||
const isJoinColumn: boolean =
|
||||
isFieldRelation(fieldMetadata) &&
|
||||
fieldMetadata.settings.joinColumnName === gqlField;
|
||||
|
||||
if (
|
||||
isUndefinedOrNull(recordGqlFields) &&
|
||||
fieldMetadata.type !== FieldMetadataType.RELATION
|
||||
(fieldMetadata.type !== FieldMetadataType.RELATION || isJoinColumn)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,12 +2,9 @@ import { z } from 'zod';
|
||||
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { metadataLabelSchema } from '@/object-metadata/validation-schemas/metadataLabelSchema';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { camelCaseStringSchema } from '~/utils/validation-schemas/camelCaseStringSchema';
|
||||
import { themeColorSchema } from 'twenty-ui/theme';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
import { camelCaseStringSchema } from '~/utils/validation-schemas/camelCaseStringSchema';
|
||||
|
||||
export const fieldMetadataItemSchema = (existingLabels?: string[]) => {
|
||||
return z.object({
|
||||
@ -38,11 +35,10 @@ export const fieldMetadataItemSchema = (existingLabels?: string[]) => {
|
||||
.nullable()
|
||||
.optional(),
|
||||
settings: z.any().optional(),
|
||||
relationDefinition: z
|
||||
relation: z
|
||||
.object({
|
||||
__typename: z.literal('RelationDefinition').optional(),
|
||||
relationId: z.string().uuid(),
|
||||
direction: z.nativeEnum(RelationDefinitionType),
|
||||
__typename: z.literal('Relation').optional(),
|
||||
type: z.nativeEnum(RelationType),
|
||||
sourceFieldMetadata: z.object({
|
||||
__typename: z.literal('Field').optional(),
|
||||
id: z.string().uuid(),
|
||||
|
||||
@ -15,6 +15,7 @@ export const objectMetadataItemSchema = z.object({
|
||||
indexMetadatas: z.array(indexMetadataItemSchema),
|
||||
icon: z.string().startsWith('Icon').trim(),
|
||||
id: z.string().uuid(),
|
||||
duplicateCriteria: z.array(z.array(z.string())),
|
||||
imageIdentifierFieldMetadataId: z.string().uuid().nullable(),
|
||||
isActive: z.boolean(),
|
||||
isCustom: z.boolean(),
|
||||
|
||||
@ -24,7 +24,7 @@ export const getAdvancedFilterInputPlaceholderText = (
|
||||
case FieldMetadataType.ACTOR:
|
||||
return 'Select actor';
|
||||
case FieldMetadataType.RELATION:
|
||||
return `Select ${fieldMetadataItem.relationDefinition?.targetObjectMetadata.nameSingular}`;
|
||||
return `Select ${fieldMetadataItem.relation?.targetObjectMetadata.nameSingular}`;
|
||||
case FieldMetadataType.SELECT:
|
||||
case FieldMetadataType.MULTI_SELECT:
|
||||
return `Select ${fieldMetadataItem.label}`;
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { isObjectRecordConnection } from '@/object-record/cache/utils/isObjectRecordConnection';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
describe('isObjectRecordConnection', () => {
|
||||
const relationDefinitionMap: { [K in RelationDefinitionType]: boolean } = {
|
||||
[RelationDefinitionType.MANY_TO_MANY]: true,
|
||||
[RelationDefinitionType.ONE_TO_MANY]: true,
|
||||
[RelationDefinitionType.MANY_TO_ONE]: false,
|
||||
[RelationDefinitionType.ONE_TO_ONE]: false,
|
||||
const relationDefinitionMap: { [K in RelationType]: boolean } = {
|
||||
[RelationType.ONE_TO_MANY]: true,
|
||||
[RelationType.MANY_TO_ONE]: false,
|
||||
};
|
||||
|
||||
it.each(Object.entries(relationDefinitionMap))(
|
||||
@ -15,8 +13,8 @@ describe('isObjectRecordConnection', () => {
|
||||
const emptyRecord = {};
|
||||
const result = isObjectRecordConnection(
|
||||
{
|
||||
direction: relation,
|
||||
} as NonNullable<FieldMetadataItem['relationDefinition']>,
|
||||
type: relation,
|
||||
} as NonNullable<FieldMetadataItem['relation']>,
|
||||
emptyRecord,
|
||||
);
|
||||
|
||||
|
||||
@ -8,10 +8,7 @@ import { getRefName } from '@/object-record/cache/utils/getRefName';
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
import { pascalCase } from '~/utils/string/pascalCase';
|
||||
|
||||
export const getRecordNodeFromRecord = <T extends ObjectRecord>({
|
||||
@ -63,13 +60,12 @@ export const getRecordNodeFromRecord = <T extends ObjectRecord>({
|
||||
|
||||
if (
|
||||
field.type === FieldMetadataType.RELATION &&
|
||||
field.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
field.relation?.type === RelationType.ONE_TO_MANY
|
||||
) {
|
||||
const oneToManyObjectMetadataItem = objectMetadataItems.find(
|
||||
(item) =>
|
||||
item.namePlural ===
|
||||
field.relationDefinition?.targetObjectMetadata.namePlural,
|
||||
field.relation?.targetObjectMetadata.namePlural,
|
||||
);
|
||||
|
||||
if (!oneToManyObjectMetadataItem) {
|
||||
@ -103,9 +99,7 @@ export const getRecordNodeFromRecord = <T extends ObjectRecord>({
|
||||
}
|
||||
|
||||
if (
|
||||
isUndefined(
|
||||
field.relationDefinition?.targetObjectMetadata.nameSingular,
|
||||
)
|
||||
isUndefined(field.relation?.targetObjectMetadata.nameSingular)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
@ -119,7 +113,7 @@ export const getRecordNodeFromRecord = <T extends ObjectRecord>({
|
||||
}
|
||||
|
||||
const typeName = getObjectTypename(
|
||||
field.relationDefinition?.targetObjectMetadata.nameSingular,
|
||||
field.relation?.targetObjectMetadata.nameSingular,
|
||||
);
|
||||
|
||||
if (computeReferences) {
|
||||
|
||||
@ -1,23 +1,20 @@
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { RecordGqlConnection } from '@/object-record/graphql/types/RecordGqlConnection';
|
||||
import { assertUnreachable } from '@/workflow/utils/assertUnreachable';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const isObjectRecordConnection = (
|
||||
relationDefinition: NonNullable<FieldMetadataItem['relationDefinition']>,
|
||||
relation: NonNullable<FieldMetadataItem['relation']>,
|
||||
value: unknown,
|
||||
): value is RecordGqlConnection => {
|
||||
switch (relationDefinition.direction) {
|
||||
case RelationDefinitionType.MANY_TO_MANY:
|
||||
case RelationDefinitionType.ONE_TO_MANY: {
|
||||
switch (relation.type) {
|
||||
case RelationType.ONE_TO_MANY: {
|
||||
return true;
|
||||
}
|
||||
case RelationDefinitionType.MANY_TO_ONE:
|
||||
case RelationDefinitionType.ONE_TO_ONE: {
|
||||
case RelationType.MANY_TO_ONE:
|
||||
return false;
|
||||
}
|
||||
default: {
|
||||
return assertUnreachable(relationDefinition.direction);
|
||||
return assertUnreachable(relation.type);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,7 +11,6 @@ describe('generateDepthOneWithoutRelationsRecordGqlFields', () => {
|
||||
{
|
||||
"avatarUrl": true,
|
||||
"city": true,
|
||||
"companyId": true,
|
||||
"createdAt": true,
|
||||
"createdBy": true,
|
||||
"deletedAt": true,
|
||||
|
||||
@ -67,6 +67,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
type
|
||||
@ -127,7 +128,6 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
employees
|
||||
id
|
||||
idealCustomerProfile
|
||||
internalCompetitions
|
||||
introVideo {
|
||||
primaryLinkUrl
|
||||
primaryLinkLabel
|
||||
@ -178,6 +178,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
personId
|
||||
petId
|
||||
position
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -229,6 +230,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
updatedAt
|
||||
}
|
||||
@ -280,6 +282,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -304,6 +307,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
personId
|
||||
petId
|
||||
properties
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
|
||||
@ -40,7 +40,6 @@ const mocks: MockedResponse[] = [
|
||||
__typename
|
||||
avatarUrl
|
||||
city
|
||||
companyId
|
||||
createdAt
|
||||
createdBy {
|
||||
source
|
||||
@ -102,7 +101,6 @@ const mocks: MockedResponse[] = [
|
||||
employees
|
||||
id
|
||||
idealCustomerProfile
|
||||
internalCompetitions
|
||||
introVideo {
|
||||
primaryLinkUrl
|
||||
primaryLinkLabel
|
||||
@ -132,6 +130,10 @@ const mocks: MockedResponse[] = [
|
||||
note {
|
||||
__typename
|
||||
body
|
||||
bodyV2 {
|
||||
blocknote
|
||||
markdown
|
||||
}
|
||||
createdAt
|
||||
createdBy {
|
||||
source
|
||||
@ -281,6 +283,22 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
}
|
||||
petId
|
||||
rocket {
|
||||
__typename
|
||||
createdAt
|
||||
createdBy {
|
||||
source
|
||||
workspaceMemberId
|
||||
name
|
||||
context
|
||||
}
|
||||
deletedAt
|
||||
id
|
||||
name
|
||||
position
|
||||
updatedAt
|
||||
}
|
||||
rocketId
|
||||
surveyResult {
|
||||
__typename
|
||||
averageEstimatedNumberOfAtomsInTheUniverse
|
||||
@ -352,7 +370,6 @@ const mocks: MockedResponse[] = [
|
||||
employees
|
||||
id
|
||||
idealCustomerProfile
|
||||
internalCompetitions
|
||||
introVideo {
|
||||
primaryLinkUrl
|
||||
primaryLinkLabel
|
||||
@ -514,6 +531,22 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
}
|
||||
petId
|
||||
rocket {
|
||||
__typename
|
||||
createdAt
|
||||
createdBy {
|
||||
source
|
||||
workspaceMemberId
|
||||
name
|
||||
context
|
||||
}
|
||||
deletedAt
|
||||
id
|
||||
name
|
||||
position
|
||||
updatedAt
|
||||
}
|
||||
rocketId
|
||||
surveyResult {
|
||||
__typename
|
||||
averageEstimatedNumberOfAtomsInTheUniverse
|
||||
@ -540,6 +573,10 @@ const mocks: MockedResponse[] = [
|
||||
__typename
|
||||
assigneeId
|
||||
body
|
||||
bodyV2 {
|
||||
blocknote
|
||||
markdown
|
||||
}
|
||||
createdAt
|
||||
createdBy {
|
||||
source
|
||||
|
||||
@ -30,7 +30,7 @@ export const useAttachRelatedRecordFromRecord = ({
|
||||
});
|
||||
|
||||
const relatedRecordObjectNameSingular =
|
||||
fieldOnObject?.relationDefinition?.targetObjectMetadata.nameSingular;
|
||||
fieldOnObject?.relation?.targetObjectMetadata.nameSingular;
|
||||
|
||||
if (!relatedRecordObjectNameSingular) {
|
||||
throw new Error(
|
||||
@ -43,7 +43,7 @@ export const useAttachRelatedRecordFromRecord = ({
|
||||
});
|
||||
|
||||
const fieldOnRelatedObject =
|
||||
fieldOnObject?.relationDefinition?.targetFieldMetadata.name;
|
||||
fieldOnObject?.relation?.targetFieldMetadata.name;
|
||||
|
||||
if (!fieldOnRelatedObject) {
|
||||
throw new Error(`Missing target field for ${fieldNameOnRecordObject}`);
|
||||
|
||||
@ -25,10 +25,10 @@ export const useDetachRelatedRecordFromRecord = ({
|
||||
});
|
||||
|
||||
const relatedRecordObjectNameSingular =
|
||||
fieldOnObject?.relationDefinition?.targetObjectMetadata.nameSingular;
|
||||
fieldOnObject?.relation?.targetObjectMetadata.nameSingular;
|
||||
|
||||
const fieldOnRelatedObject =
|
||||
fieldOnObject?.relationDefinition?.targetFieldMetadata.name;
|
||||
fieldOnObject?.relation?.targetFieldMetadata.name;
|
||||
|
||||
if (!relatedRecordObjectNameSingular) {
|
||||
throw new Error(
|
||||
|
||||
@ -40,6 +40,7 @@ const mocks: MockedResponse[] = [
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
position
|
||||
timeFormat
|
||||
timeZone
|
||||
updatedAt
|
||||
@ -76,6 +77,7 @@ const mocks: MockedResponse[] = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
type
|
||||
@ -112,6 +114,7 @@ const mocks: MockedResponse[] = [
|
||||
personId
|
||||
petId
|
||||
position
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -124,7 +127,6 @@ const mocks: MockedResponse[] = [
|
||||
}
|
||||
id
|
||||
idealCustomerProfile
|
||||
internalCompetitions
|
||||
introVideo {
|
||||
primaryLinkUrl
|
||||
primaryLinkLabel
|
||||
@ -148,6 +150,7 @@ const mocks: MockedResponse[] = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
updatedAt
|
||||
}
|
||||
@ -248,6 +251,7 @@ const mocks: MockedResponse[] = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -272,6 +276,7 @@ const mocks: MockedResponse[] = [
|
||||
personId
|
||||
petId
|
||||
properties
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
|
||||
@ -22,7 +22,7 @@ import { RecordFieldComponentInstanceContext } from '@/object-record/record-fiel
|
||||
import { MultipleRecordPickerHotkeyScope } from '@/object-record/record-picker/multiple-record-picker/types/MultipleRecordPickerHotkeyScope';
|
||||
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
const RelationWorkspaceSetterEffect = () => {
|
||||
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
|
||||
@ -49,7 +49,7 @@ const RelationManyFieldInputWithContext = () => {
|
||||
iconName: 'IconLink',
|
||||
metadata: {
|
||||
fieldName: 'people',
|
||||
relationType: RelationDefinitionType.ONE_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
relationObjectMetadataNamePlural: 'companies',
|
||||
relationObjectMetadataNameSingular: CoreObjectNameSingular.Company,
|
||||
objectMetadataNameSingular: 'company',
|
||||
|
||||
@ -9,11 +9,8 @@ import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';
|
||||
import { viewableRecordNameSingularState } from '@/object-record/record-right-drawer/states/viewableRecordNameSingularState';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
type RecordDetailRelationSectionProps = {
|
||||
relationObjectMetadataNameSingular: string;
|
||||
@ -38,8 +35,8 @@ export const useAddNewRecordAndOpenRightDrawer = ({
|
||||
|
||||
const { updateOneRecord } = useUpdateOneRecord({
|
||||
objectNameSingular:
|
||||
relationFieldMetadataItem?.relationDefinition?.targetObjectMetadata
|
||||
.nameSingular ?? 'workspaceMember',
|
||||
relationFieldMetadataItem?.relation?.targetObjectMetadata.nameSingular ??
|
||||
'workspaceMember',
|
||||
});
|
||||
|
||||
const { openRecordInCommandMenu } = useOpenRecordInCommandMenu();
|
||||
@ -47,8 +44,7 @@ export const useAddNewRecordAndOpenRightDrawer = ({
|
||||
if (
|
||||
relationObjectMetadataNameSingular === 'workspaceMember' ||
|
||||
!isDefined(
|
||||
relationFieldMetadataItem?.relationDefinition?.targetObjectMetadata
|
||||
.nameSingular,
|
||||
relationFieldMetadataItem?.relation?.targetObjectMetadata.nameSingular,
|
||||
)
|
||||
) {
|
||||
return {
|
||||
@ -83,24 +79,22 @@ export const useAddNewRecordAndOpenRightDrawer = ({
|
||||
: { id: newRecordId, name: searchInput ?? '' };
|
||||
|
||||
if (
|
||||
relationFieldMetadataItem?.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
relationFieldMetadataItem?.relation?.type === RelationType.MANY_TO_ONE
|
||||
) {
|
||||
createRecordPayload[
|
||||
`${relationFieldMetadataItem?.relationDefinition?.sourceFieldMetadata.name}Id`
|
||||
`${relationFieldMetadataItem?.relation?.sourceFieldMetadata.name}Id`
|
||||
] = recordId;
|
||||
}
|
||||
|
||||
await createOneRecord(createRecordPayload);
|
||||
|
||||
if (
|
||||
relationFieldMetadataItem?.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
relationFieldMetadataItem?.relation?.type === RelationType.ONE_TO_MANY
|
||||
) {
|
||||
await updateOneRecord({
|
||||
idToUpdate: recordId,
|
||||
updateOneRecordInput: {
|
||||
[`${relationFieldMetadataItem?.relationDefinition?.targetFieldMetadata.name}Id`]:
|
||||
[`${relationFieldMetadataItem?.relation?.targetFieldMetadata.name}Id`]:
|
||||
newRecordId,
|
||||
},
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
import { ThemeColor } from 'twenty-ui/theme';
|
||||
import { z } from 'zod';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { CurrencyCode } from './CurrencyCode';
|
||||
|
||||
type BaseFieldMetadata = {
|
||||
@ -132,7 +132,7 @@ export type FieldRelationMetadata = BaseFieldMetadata & {
|
||||
relationObjectMetadataNamePlural: string;
|
||||
relationObjectMetadataNameSingular: string;
|
||||
relationObjectMetadataId: string;
|
||||
relationType?: RelationDefinitionType;
|
||||
relationType?: RelationType;
|
||||
targetFieldMetadataName?: string;
|
||||
useEditButton?: boolean;
|
||||
settings?: null;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { isFieldRelation } from '@/object-record/record-field/types/guards/isFieldRelation';
|
||||
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { FieldDefinition } from '../FieldDefinition';
|
||||
import { FieldMetadata, FieldRelationMetadata } from '../FieldMetadata';
|
||||
|
||||
@ -8,4 +8,4 @@ export const isFieldRelationFromManyObjects = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type' | 'metadata'>,
|
||||
): field is FieldDefinition<FieldRelationMetadata> =>
|
||||
isFieldRelation(field) &&
|
||||
field.metadata.relationType === RelationDefinitionType.ONE_TO_MANY;
|
||||
field.metadata.relationType === RelationType.ONE_TO_MANY;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { isFieldRelation } from '@/object-record/record-field/types/guards/isFieldRelation';
|
||||
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { FieldDefinition } from '../FieldDefinition';
|
||||
import { FieldMetadata, FieldRelationMetadata } from '../FieldMetadata';
|
||||
|
||||
@ -8,4 +8,4 @@ export const isFieldRelationToOneObject = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type' | 'metadata'>,
|
||||
): field is FieldDefinition<FieldRelationMetadata> =>
|
||||
isFieldRelation(field) &&
|
||||
field.metadata.relationType === RelationDefinitionType.MANY_TO_ONE;
|
||||
field.metadata.relationType === RelationType.MANY_TO_ONE;
|
||||
|
||||
@ -14,6 +14,10 @@ const companyMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'company',
|
||||
)!;
|
||||
|
||||
const petMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'pet',
|
||||
)!;
|
||||
|
||||
const personMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'person',
|
||||
)!;
|
||||
@ -1364,21 +1368,21 @@ describe('should work as expected for the different field types', () => {
|
||||
});
|
||||
|
||||
it('select field type with empty options', () => {
|
||||
const selectFieldMetadata = companyMockObjectMetadataItem.fields.find(
|
||||
const selectFieldMetadata = petMockObjectMetadataItem.fields.find(
|
||||
(field) => field.type === FieldMetadataType.SELECT,
|
||||
);
|
||||
|
||||
if (!selectFieldMetadata) {
|
||||
throw new Error(
|
||||
`Select field metadata not found ${companyMockObjectMetadataItem.fields.map((field) => [field.name, field.type])}`,
|
||||
`Select field metadata not found ${petMockObjectMetadataItem.fields.map((field) => [field.name, field.type])}`,
|
||||
);
|
||||
}
|
||||
|
||||
const selectFilterIs: RecordFilter = {
|
||||
id: 'company-select-filter-is',
|
||||
value: '["option1",""]',
|
||||
id: 'pet-select-filter-is',
|
||||
value: '["DOG",""]',
|
||||
fieldMetadataId: selectFieldMetadata?.id,
|
||||
displayValue: '["option1",""]',
|
||||
displayValue: '["Dog",""]',
|
||||
operand: ViewFilterOperand.Is,
|
||||
label: 'Select',
|
||||
type: FieldMetadataType.SELECT,
|
||||
@ -1386,9 +1390,9 @@ describe('should work as expected for the different field types', () => {
|
||||
|
||||
const selectFilterIsNot: RecordFilter = {
|
||||
id: 'company-select-filter-is-not',
|
||||
value: '["option1",""]',
|
||||
value: '["DOG",""]',
|
||||
fieldMetadataId: selectFieldMetadata.id,
|
||||
displayValue: '["option1",""]',
|
||||
displayValue: '["Dog",""]',
|
||||
operand: ViewFilterOperand.IsNot,
|
||||
label: 'Select',
|
||||
type: FieldMetadataType.SELECT,
|
||||
@ -1398,7 +1402,7 @@ describe('should work as expected for the different field types', () => {
|
||||
filterValueDependencies: mockFilterValueDependencies,
|
||||
recordFilters: [selectFilterIs, selectFilterIsNot],
|
||||
recordFilterGroups: [],
|
||||
fields: companyMockObjectMetadataItem.fields,
|
||||
fields: petMockObjectMetadataItem.fields,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
@ -1407,7 +1411,7 @@ describe('should work as expected for the different field types', () => {
|
||||
or: [
|
||||
{
|
||||
[selectFieldMetadata.name]: {
|
||||
in: ['option1'],
|
||||
in: ['DOG'],
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1422,7 +1426,7 @@ describe('should work as expected for the different field types', () => {
|
||||
{
|
||||
not: {
|
||||
[selectFieldMetadata.name]: {
|
||||
in: ['option1'],
|
||||
in: ['DOG'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -17,52 +17,52 @@ import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedM
|
||||
|
||||
const mockPerson = {
|
||||
__typename: 'Person',
|
||||
updatedAt: '2021-08-03T19:20:06.000Z',
|
||||
whatsapp: {
|
||||
primaryPhoneNumber: '+1',
|
||||
primaryPhoneCountryCode: '234-567-890',
|
||||
primaryPhoneCallingCode: '+33',
|
||||
additionalPhones: [],
|
||||
avatarUrl: 'avatarUrl',
|
||||
city: 'city',
|
||||
companyId: '1',
|
||||
createdAt: '2021-08-03T19:20:06.000Z',
|
||||
createdBy: {
|
||||
name: 'name',
|
||||
source: 'source',
|
||||
workspaceMemberId: '1',
|
||||
},
|
||||
deletedAt: null,
|
||||
emails: {
|
||||
additionalEmails: [],
|
||||
primaryEmail: 'email',
|
||||
},
|
||||
id: '123',
|
||||
intro: 'intro',
|
||||
jobTitle: 'jobTitle',
|
||||
linkedinLink: {
|
||||
primaryLinkUrl: 'https://www.linkedin.com',
|
||||
primaryLinkLabel: 'linkedin',
|
||||
primaryLinkUrl: 'https://www.linkedin.com',
|
||||
secondaryLinks: ['https://www.linkedin.com'],
|
||||
},
|
||||
name: {
|
||||
firstName: 'firstName',
|
||||
lastName: 'lastName',
|
||||
},
|
||||
emails: {
|
||||
primaryEmail: 'email',
|
||||
additionalEmails: [],
|
||||
performanceRating: 1,
|
||||
phones: {
|
||||
additionalPhones: [],
|
||||
primaryPhoneCountryCode: '234-567-890',
|
||||
primaryPhoneNumber: '+1',
|
||||
},
|
||||
position: 'position',
|
||||
createdBy: {
|
||||
source: 'source',
|
||||
workspaceMemberId: '1',
|
||||
name: 'name',
|
||||
updatedAt: '2021-08-03T19:20:06.000Z',
|
||||
whatsapp: {
|
||||
additionalPhones: [],
|
||||
primaryPhoneCallingCode: '+33',
|
||||
primaryPhoneCountryCode: '234-567-890',
|
||||
primaryPhoneNumber: '+1',
|
||||
},
|
||||
avatarUrl: 'avatarUrl',
|
||||
jobTitle: 'jobTitle',
|
||||
workPreference: 'workPreference',
|
||||
xLink: {
|
||||
primaryLinkUrl: 'https://www.linkedin.com',
|
||||
primaryLinkLabel: 'linkedin',
|
||||
primaryLinkUrl: 'https://www.linkedin.com',
|
||||
secondaryLinks: ['https://www.linkedin.com'],
|
||||
},
|
||||
performanceRating: 1,
|
||||
createdAt: '2021-08-03T19:20:06.000Z',
|
||||
phones: {
|
||||
primaryPhoneNumber: '+1',
|
||||
primaryPhoneCountryCode: '234-567-890',
|
||||
additionalPhones: [],
|
||||
},
|
||||
id: '123',
|
||||
city: 'city',
|
||||
companyId: '1',
|
||||
intro: 'intro',
|
||||
deletedAt: null,
|
||||
workPreference: 'workPreference',
|
||||
};
|
||||
|
||||
const Wrapper = getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
@ -238,7 +238,7 @@ describe('useRecordData', () => {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
},
|
||||
position: 10,
|
||||
position: 9,
|
||||
showLabel: undefined,
|
||||
size: 100,
|
||||
type: 'DATE_TIME',
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
||||
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
import { displayedExportProgress, generateCsv } from '../useExportRecords';
|
||||
|
||||
jest.useFakeTimers();
|
||||
@ -23,7 +20,7 @@ describe('generateCsv', () => {
|
||||
label: 'Relation',
|
||||
metadata: {
|
||||
fieldName: 'relation',
|
||||
relationType: RelationDefinitionType.MANY_TO_ONE,
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
},
|
||||
},
|
||||
] as ColumnDefinition<FieldMetadata>[];
|
||||
|
||||
@ -15,7 +15,7 @@ import { COMPOSITE_FIELD_SUB_FIELD_LABELS } from '@/settings/data-model/constant
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
@ -39,7 +39,7 @@ export const generateCsv: GenerateExport = ({
|
||||
const columnsToExport = columns.filter(
|
||||
(col) =>
|
||||
!('relationType' in col.metadata && col.metadata.relationType) ||
|
||||
col.metadata.relationType === RelationDefinitionType.MANY_TO_ONE,
|
||||
col.metadata.relationType === RelationType.MANY_TO_ONE,
|
||||
);
|
||||
|
||||
const objectIdColumn: ColumnDefinition<FieldMetadata> = {
|
||||
|
||||
@ -96,7 +96,7 @@ export const FieldsCard = ({
|
||||
) &&
|
||||
getObjectPermissionsForObject(
|
||||
objectPermissionsByObjectMetadataId,
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata.id,
|
||||
fieldMetadataItem.relation?.targetObjectMetadata.id,
|
||||
).canReadObjectRecords,
|
||||
);
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ import {
|
||||
import { LightIconButton } from 'twenty-ui/input';
|
||||
import { MenuItem } from 'twenty-ui/navigation';
|
||||
import { AnimatedEaseInOut } from 'twenty-ui/utilities';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
const StyledListItem = styled(RecordDetailRecordsListItem)<{
|
||||
isDropdownOpen?: boolean;
|
||||
@ -113,7 +113,7 @@ export const RecordDetailRelationRecordsListItem = ({
|
||||
relationType,
|
||||
} = fieldDefinition.metadata as FieldRelationMetadata;
|
||||
|
||||
const isToOneObject = relationType === RelationDefinitionType.MANY_TO_ONE;
|
||||
const isToOneObject = relationType === RelationType.MANY_TO_ONE;
|
||||
const { objectMetadataItem: relationObjectMetadataItem } =
|
||||
useObjectMetadataItem({
|
||||
objectNameSingular: relationObjectMetadataNameSingular,
|
||||
|
||||
@ -21,7 +21,7 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||
|
||||
type RecordDetailRelationSectionProps = {
|
||||
@ -57,8 +57,8 @@ export const RecordDetailRelationSection = ({
|
||||
>(recordStoreFamilySelector({ recordId, fieldName }));
|
||||
|
||||
// TODO: use new relation type
|
||||
const isToOneObject = relationType === RelationDefinitionType.MANY_TO_ONE;
|
||||
const isToManyObjects = relationType === RelationDefinitionType.ONE_TO_MANY;
|
||||
const isToOneObject = relationType === RelationType.MANY_TO_ONE;
|
||||
const isToManyObjects = relationType === RelationType.ONE_TO_MANY;
|
||||
|
||||
const relationRecords: ObjectRecord[] =
|
||||
fieldValue && isToOneObject
|
||||
|
||||
@ -28,7 +28,7 @@ import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';
|
||||
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
|
||||
import { IconForbid, IconPencil, IconPlus } from 'twenty-ui/display';
|
||||
import { LightIconButton } from 'twenty-ui/input';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
type RecordDetailRelationSectionDropdownProps = {
|
||||
loading: boolean;
|
||||
@ -61,8 +61,8 @@ export const RecordDetailRelationSectionDropdown = ({
|
||||
>(recordStoreFamilySelector({ recordId, fieldName }));
|
||||
|
||||
// TODO: use new relation type
|
||||
const isToOneObject = relationType === RelationDefinitionType.MANY_TO_ONE;
|
||||
const isToManyObjects = relationType === RelationDefinitionType.ONE_TO_MANY;
|
||||
const isToOneObject = relationType === RelationType.MANY_TO_ONE;
|
||||
const isToManyObjects = relationType === RelationType.ONE_TO_MANY;
|
||||
|
||||
const relationRecords: ObjectRecord[] =
|
||||
fieldValue && isToOneObject
|
||||
|
||||
@ -36,8 +36,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: '0cf72416-3d94-4d94-abf3-7dc9d734435b',
|
||||
direction: 'MANY_TO_ONE',
|
||||
sourceObjectMetadata: {
|
||||
@ -80,7 +80,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: "''",
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -98,7 +98,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: "''",
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -116,8 +116,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: 'd76f949d-023d-4b45-a71e-f39e3b1562ba',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -160,8 +160,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: 'a5a61d23-8ac9-4014-9441-ec3a1781a661',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -204,8 +204,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: '456f7875-b48c-4795-a0c7-a69d7339afee',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -248,7 +248,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: 'now',
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -266,8 +266,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: '31542774-fb15-4d01-b00b-8fc94887f458',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -313,7 +313,7 @@ export const mockPerformance = {
|
||||
primaryLinkLabel: "''",
|
||||
},
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -331,8 +331,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: 'c0cc3456-afa4-46e0-820d-2db0b63a8273',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -375,7 +375,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: "''",
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -393,7 +393,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -411,7 +411,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: "''",
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -429,7 +429,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: "''",
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -447,7 +447,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: 'now',
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -465,7 +465,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -483,8 +483,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: '25150feb-fcd7-407e-b5fa-ffe58a0450ac',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -530,7 +530,7 @@ export const mockPerformance = {
|
||||
firstName: "''",
|
||||
},
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -551,7 +551,7 @@ export const mockPerformance = {
|
||||
primaryLinkLabel: "''",
|
||||
},
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
{
|
||||
__typename: 'field',
|
||||
@ -569,8 +569,8 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationDefinition: {
|
||||
__typename: 'RelationDefinition',
|
||||
relation: {
|
||||
__typename: 'Relation',
|
||||
relationId: 'e2eb7156-6e65-4bf8-922b-670179744f27',
|
||||
direction: 'ONE_TO_MANY',
|
||||
sourceObjectMetadata: {
|
||||
@ -613,7 +613,7 @@ export const mockPerformance = {
|
||||
updatedAt: '2024-05-16T10:54:27.788Z',
|
||||
defaultValue: 'uuid',
|
||||
options: null,
|
||||
relationDefinition: null,
|
||||
relation: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@ -35,7 +35,7 @@ export const useBuildRecordInputFromFilters = ({
|
||||
const value = buildValueFromFilter({
|
||||
filter,
|
||||
options: fieldMetadataItem.options ?? undefined,
|
||||
relationType: fieldMetadataItem.relationDefinition?.direction,
|
||||
relationType: fieldMetadataItem.relation?.type,
|
||||
currentWorkspaceMember: currentWorkspaceMember ?? undefined,
|
||||
label: filter.label,
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ import { FilterableFieldType } from '@/object-record/record-filter/types/Filtera
|
||||
import { RecordFilter } from '@/object-record/record-filter/types/RecordFilter';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { ColorScheme } from '@/workspace-member/types/WorkspaceMember';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { buildValueFromFilter } from './buildRecordInputFromFilter';
|
||||
|
||||
// TODO: fix the dates, and test the not supported types
|
||||
@ -238,7 +238,7 @@ describe('buildValueFromFilter', () => {
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1'],
|
||||
}),
|
||||
relationType: RelationDefinitionType.MANY_TO_ONE,
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
label: 'belongs to one',
|
||||
expected: 'record-1',
|
||||
},
|
||||
@ -248,7 +248,7 @@ describe('buildValueFromFilter', () => {
|
||||
isCurrentWorkspaceMemberSelected: true,
|
||||
selectedRecordIds: ['record-1'],
|
||||
}),
|
||||
relationType: RelationDefinitionType.MANY_TO_ONE,
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
label: 'Assignee',
|
||||
expected: 'current-workspace-member-id',
|
||||
},
|
||||
@ -258,7 +258,7 @@ describe('buildValueFromFilter', () => {
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1', 'record-2'],
|
||||
}),
|
||||
relationType: RelationDefinitionType.MANY_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
label: 'hasmany',
|
||||
expected: undefined,
|
||||
},
|
||||
@ -268,7 +268,7 @@ describe('buildValueFromFilter', () => {
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1'],
|
||||
}),
|
||||
relationType: RelationDefinitionType.MANY_TO_ONE,
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
label: 'Assignee',
|
||||
expected: undefined,
|
||||
},
|
||||
@ -278,7 +278,7 @@ describe('buildValueFromFilter', () => {
|
||||
isCurrentWorkspaceMemberSelected: false,
|
||||
selectedRecordIds: ['record-1'],
|
||||
}),
|
||||
relationType: RelationDefinitionType.MANY_TO_ONE,
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
label: 'Assignee',
|
||||
expected: undefined,
|
||||
},
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
import { FILTER_OPERANDS_MAP } from '@/object-record/record-filter/utils/getRecordFilterOperands';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { assertUnreachable, parseJson } from 'twenty-shared/utils';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const buildValueFromFilter = ({
|
||||
filter,
|
||||
@ -20,7 +20,7 @@ export const buildValueFromFilter = ({
|
||||
}: {
|
||||
filter: RecordFilter;
|
||||
options?: FieldMetadataItemOption[];
|
||||
relationType?: RelationDefinitionType;
|
||||
relationType?: RelationType;
|
||||
currentWorkspaceMember?: CurrentWorkspaceMember;
|
||||
label?: string;
|
||||
}) => {
|
||||
@ -269,7 +269,7 @@ const computeValueFromFilterMultiSelect = (
|
||||
const computeValueFromFilterRelation = (
|
||||
operand: RecordFilterToRecordInputOperand<'RELATION'>,
|
||||
value: string,
|
||||
relationType?: RelationDefinitionType,
|
||||
relationType?: RelationType,
|
||||
currentWorkspaceMember?: CurrentWorkspaceMember,
|
||||
label?: string,
|
||||
) => {
|
||||
@ -279,10 +279,7 @@ const computeValueFromFilterRelation = (
|
||||
isCurrentWorkspaceMemberSelected: boolean;
|
||||
selectedRecordIds: string[];
|
||||
}>(value);
|
||||
if (
|
||||
relationType === RelationDefinitionType.MANY_TO_ONE ||
|
||||
relationType === RelationDefinitionType.ONE_TO_ONE
|
||||
) {
|
||||
if (relationType === RelationType.MANY_TO_ONE) {
|
||||
if (label === 'Assignee') {
|
||||
return parsedValue?.isCurrentWorkspaceMemberSelected
|
||||
? currentWorkspaceMember?.id
|
||||
|
||||
@ -40,6 +40,7 @@ const companyMocks = [
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
position
|
||||
timeFormat
|
||||
timeZone
|
||||
updatedAt
|
||||
@ -76,6 +77,7 @@ const companyMocks = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
type
|
||||
@ -112,6 +114,7 @@ const companyMocks = [
|
||||
personId
|
||||
petId
|
||||
position
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -124,7 +127,6 @@ const companyMocks = [
|
||||
}
|
||||
id
|
||||
idealCustomerProfile
|
||||
internalCompetitions
|
||||
introVideo {
|
||||
primaryLinkUrl
|
||||
primaryLinkLabel
|
||||
@ -148,6 +150,7 @@ const companyMocks = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
updatedAt
|
||||
}
|
||||
@ -248,6 +251,7 @@ const companyMocks = [
|
||||
opportunityId
|
||||
personId
|
||||
petId
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
@ -272,6 +276,7 @@ const companyMocks = [
|
||||
personId
|
||||
petId
|
||||
properties
|
||||
rocketId
|
||||
surveyResultId
|
||||
taskId
|
||||
updatedAt
|
||||
|
||||
@ -6,10 +6,7 @@ import { useOpenSpreadsheetImportDialog } from '@/spreadsheet-import/hooks/useOp
|
||||
import { SpreadsheetImportDialogOptions } from '@/spreadsheet-import/types';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useOpenObjectRecordsSpreadsheetImportDialog = (
|
||||
objectNameSingular: string,
|
||||
@ -41,8 +38,7 @@ export const useOpenObjectRecordsSpreadsheetImportDialog = (
|
||||
fieldMetadataItem.name !== 'createdAt' &&
|
||||
fieldMetadataItem.name !== 'updatedAt' &&
|
||||
(fieldMetadataItem.type !== FieldMetadataType.RELATION ||
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE),
|
||||
fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE),
|
||||
)
|
||||
.sort((fieldMetadataItemA, fieldMetadataItemB) =>
|
||||
fieldMetadataItemA.name.localeCompare(fieldMetadataItemB.name),
|
||||
|
||||
@ -15,7 +15,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { buildOptimisticActorFieldValueFromCurrentWorkspaceMember } from '@/object-record/utils/buildOptimisticActorFieldValueFromCurrentWorkspaceMember';
|
||||
import { getForeignKeyNameFromRelationFieldName } from '@/object-record/utils/getForeignKeyNameFromRelationFieldName';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
|
||||
type ComputeOptimisticCacheRecordInputArgs = {
|
||||
@ -67,16 +67,16 @@ export const computeOptimisticRecordFromInput = ({
|
||||
|
||||
if (isFieldUuid(fieldMetadataItem)) {
|
||||
const isRelationFieldId = objectMetadataItem.fields.some(
|
||||
({ type, relationDefinition }) => {
|
||||
({ type, relation }) => {
|
||||
if (type !== FieldMetadataType.RELATION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDefined(relationDefinition)) {
|
||||
if (!isDefined(relation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const sourceFieldName = relationDefinition.sourceFieldMetadata.name;
|
||||
const sourceFieldName = relation.sourceFieldMetadata.name;
|
||||
return (
|
||||
getForeignKeyNameFromRelationFieldName(sourceFieldName) ===
|
||||
fieldMetadataItem.name
|
||||
@ -115,16 +115,12 @@ export const computeOptimisticRecordFromInput = ({
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
) {
|
||||
if (fieldMetadataItem.relation?.type === RelationType.ONE_TO_MANY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const isManyToOneRelation =
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE;
|
||||
fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE;
|
||||
if (!isManyToOneRelation) {
|
||||
continue;
|
||||
}
|
||||
@ -166,7 +162,7 @@ export const computeOptimisticRecordFromInput = ({
|
||||
}
|
||||
|
||||
const targetNameSingular =
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata.nameSingular;
|
||||
fieldMetadataItem.relation?.targetObjectMetadata.nameSingular;
|
||||
const targetObjectMetataDataItem = objectMetadataItems.find(
|
||||
({ nameSingular }) => nameSingular === targetNameSingular,
|
||||
);
|
||||
|
||||
@ -1,20 +1,10 @@
|
||||
import { TABLE_COLUMNS_DENY_LIST } from '@/object-record/constants/TableColumnsDenyList';
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { isFieldRelation } from '@/object-record/record-field/types/guards/isFieldRelation';
|
||||
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const filterAvailableTableColumns = (
|
||||
columnDefinition: ColumnDefinition<FieldMetadata>,
|
||||
): boolean => {
|
||||
if (
|
||||
isFieldRelation(columnDefinition) &&
|
||||
columnDefinition.metadata?.relationType ===
|
||||
RelationDefinitionType.MANY_TO_MANY
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TABLE_COLUMNS_DENY_LIST.includes(columnDefinition.metadata.fieldName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { FieldActorValue } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { assertUnreachable } from '@/workflow/utils/assertUnreachable';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export type GenerateEmptyFieldValueArgs = {
|
||||
fieldMetadataItem: Pick<FieldMetadataItem, 'type' | 'relationDefinition'>;
|
||||
fieldMetadataItem: Pick<FieldMetadataItem, 'type' | 'relation'>;
|
||||
};
|
||||
// TODO strictly type each fieldValue following their FieldMetadataType
|
||||
export const generateEmptyFieldValue = ({
|
||||
@ -60,10 +57,7 @@ export const generateEmptyFieldValue = ({
|
||||
return true;
|
||||
}
|
||||
case FieldMetadataType.RELATION: {
|
||||
if (
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
) {
|
||||
if (fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,8 @@ export const getRecordChipGenerators = (
|
||||
|
||||
const currentObjectNameSingular = objectMetadataItem.nameSingular;
|
||||
const fieldObjectNameSingular =
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata
|
||||
.nameSingular ?? undefined;
|
||||
fieldMetadataItem.relation?.targetObjectMetadata.nameSingular ??
|
||||
undefined;
|
||||
|
||||
const objectNameSingularToFind = isLabelIdentifier
|
||||
? currentObjectNameSingular
|
||||
|
||||
@ -2,10 +2,7 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { isObjectMetadataAvailableForRelation } from '@/object-metadata/utils/isObjectMetadataAvailableForRelation';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const isFieldCellSupported = (
|
||||
fieldMetadataItem: FieldMetadataItem,
|
||||
@ -23,7 +20,7 @@ export const isFieldCellSupported = (
|
||||
|
||||
if (fieldMetadataItem.type === FieldMetadataType.RELATION) {
|
||||
const relationObjectMetadataItemId =
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata.id;
|
||||
fieldMetadataItem.relation?.targetObjectMetadata.id;
|
||||
|
||||
const relationObjectMetadataItem = objectMetadataItems.find(
|
||||
(item) => item.id === relationObjectMetadataItemId,
|
||||
@ -31,28 +28,25 @@ export const isFieldCellSupported = (
|
||||
|
||||
// Hack to display targets on Notes and Tasks
|
||||
if (
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata
|
||||
?.nameSingular === CoreObjectNameSingular.NoteTarget &&
|
||||
fieldMetadataItem.relationDefinition?.sourceObjectMetadata
|
||||
.nameSingular === CoreObjectNameSingular.Note
|
||||
fieldMetadataItem.relation?.targetObjectMetadata?.nameSingular ===
|
||||
CoreObjectNameSingular.NoteTarget &&
|
||||
fieldMetadataItem.relation?.sourceObjectMetadata.nameSingular ===
|
||||
CoreObjectNameSingular.Note
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata
|
||||
?.nameSingular === CoreObjectNameSingular.TaskTarget &&
|
||||
fieldMetadataItem.relationDefinition?.sourceObjectMetadata
|
||||
.nameSingular === CoreObjectNameSingular.Task
|
||||
fieldMetadataItem.relation?.targetObjectMetadata?.nameSingular ===
|
||||
CoreObjectNameSingular.TaskTarget &&
|
||||
fieldMetadataItem.relation?.sourceObjectMetadata.nameSingular ===
|
||||
CoreObjectNameSingular.Task
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
!fieldMetadataItem.relationDefinition ||
|
||||
// TODO: Many to many relations are not supported yet.
|
||||
fieldMetadataItem.relationDefinition.direction ===
|
||||
RelationDefinitionType.MANY_TO_MANY ||
|
||||
!fieldMetadataItem.relation ||
|
||||
!relationObjectMetadataItem ||
|
||||
!isObjectMetadataAvailableForRelation(relationObjectMetadataItem)
|
||||
) {
|
||||
|
||||
@ -5,7 +5,7 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { generateEmptyFieldValue } from '@/object-record/utils/generateEmptyFieldValue';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FieldMetadataType, RelationDefinitionType } from '~/generated/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated/graphql';
|
||||
|
||||
type PrefillRecordArgs = {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
@ -19,19 +19,26 @@ export const prefillRecord = <T extends ObjectRecord>({
|
||||
objectMetadataItem.fields
|
||||
.map((fieldMetadataItem) => {
|
||||
const inputValue = input[fieldMetadataItem.name];
|
||||
if (
|
||||
fieldMetadataItem.type === FieldMetadataType.RELATION &&
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
) {
|
||||
throwIfInputRelationDataIsInconsistent(input, fieldMetadataItem);
|
||||
}
|
||||
|
||||
const fieldValue = isUndefined(inputValue)
|
||||
? generateEmptyFieldValue({ fieldMetadataItem })
|
||||
: inputValue;
|
||||
return [fieldMetadataItem.name, fieldValue];
|
||||
if (
|
||||
fieldMetadataItem.type === FieldMetadataType.RELATION &&
|
||||
fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE
|
||||
) {
|
||||
const joinColumnValue =
|
||||
input[fieldMetadataItem.settings?.joinColumnName];
|
||||
throwIfInputRelationDataIsInconsistent(input, fieldMetadataItem);
|
||||
|
||||
return [
|
||||
[fieldMetadataItem.name, fieldValue],
|
||||
[fieldMetadataItem.settings?.joinColumnName, joinColumnValue],
|
||||
];
|
||||
}
|
||||
|
||||
return [[fieldMetadataItem.name, fieldValue]];
|
||||
})
|
||||
.flat()
|
||||
.filter(isDefined),
|
||||
) as T;
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { isSystemSearchVectorField } from '@/object-record/utils/isSystemSearchVectorField';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
|
||||
export const sanitizeRecordInput = ({
|
||||
@ -43,8 +43,7 @@ export const sanitizeRecordInput = ({
|
||||
if (
|
||||
isDefined(fieldMetadataItem) &&
|
||||
fieldMetadataItem.type === FieldMetadataType.RELATION &&
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE
|
||||
) {
|
||||
const relationIdFieldName = `${fieldMetadataItem.name}Id`;
|
||||
const relationIdFieldMetadataItem = objectMetadataItem.fields.find(
|
||||
@ -61,8 +60,7 @@ export const sanitizeRecordInput = ({
|
||||
if (
|
||||
isDefined(fieldMetadataItem) &&
|
||||
fieldMetadataItem.type === FieldMetadataType.RELATION &&
|
||||
fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
fieldMetadataItem.relation?.type === RelationType.ONE_TO_MANY
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { IconComponent, IllustrationIconOneToMany } from 'twenty-ui/display';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import OneToManySvg from '../assets/OneToMany.svg';
|
||||
import OneToOneSvg from '../assets/OneToOne.svg';
|
||||
import { RelationType } from '../types/RelationType';
|
||||
import {
|
||||
IconComponent,
|
||||
IllustrationIconManyToMany,
|
||||
IllustrationIconOneToMany,
|
||||
IllustrationIconOneToOne,
|
||||
} from 'twenty-ui/display';
|
||||
|
||||
export const RELATION_TYPES: Record<
|
||||
RelationType,
|
||||
@ -18,27 +11,15 @@ export const RELATION_TYPES: Record<
|
||||
isImageFlipped?: boolean;
|
||||
}
|
||||
> = {
|
||||
[RelationDefinitionType.ONE_TO_MANY]: {
|
||||
[RelationType.ONE_TO_MANY]: {
|
||||
label: 'Has many',
|
||||
Icon: IllustrationIconOneToMany,
|
||||
imageSrc: OneToManySvg,
|
||||
},
|
||||
[RelationDefinitionType.ONE_TO_ONE]: {
|
||||
label: 'Has one',
|
||||
Icon: IllustrationIconOneToOne,
|
||||
imageSrc: OneToOneSvg,
|
||||
},
|
||||
[RelationDefinitionType.MANY_TO_ONE]: {
|
||||
[RelationType.MANY_TO_ONE]: {
|
||||
label: 'Belongs to one',
|
||||
Icon: IllustrationIconOneToMany,
|
||||
imageSrc: OneToManySvg,
|
||||
isImageFlipped: true,
|
||||
},
|
||||
// Not supported yet
|
||||
[RelationDefinitionType.MANY_TO_MANY]: {
|
||||
label: 'Belongs to many',
|
||||
Icon: IllustrationIconManyToMany,
|
||||
imageSrc: OneToManySvg,
|
||||
isImageFlipped: true,
|
||||
},
|
||||
};
|
||||
|
||||
@ -10,14 +10,13 @@ import { fieldMetadataItemSchema } from '@/object-metadata/validation-schemas/fi
|
||||
import { FIELD_NAME_MAXIMUM_LENGTH } from '@/settings/data-model/constants/FieldNameMaximumLength';
|
||||
import { RELATION_TYPES } from '@/settings/data-model/constants/RelationTypes';
|
||||
import { useRelationSettingsFormInitialValues } from '@/settings/data-model/fields/forms/relation/hooks/useRelationSettingsFormInitialValues';
|
||||
import { RelationType } from '@/settings/data-model/types/RelationType';
|
||||
import { IconPicker } from '@/ui/input/components/IconPicker';
|
||||
import { Select } from '@/ui/input/components/Select';
|
||||
import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const settingsDataModelFieldRelationFormSchema = z.object({
|
||||
relation: z.object({
|
||||
@ -37,10 +36,7 @@ export const settingsDataModelFieldRelationFormSchema = z.object({
|
||||
),
|
||||
objectMetadataId: z.string().uuid(),
|
||||
type: z.enum(
|
||||
Object.keys(RELATION_TYPES) as [
|
||||
RelationDefinitionType,
|
||||
...RelationDefinitionType[],
|
||||
],
|
||||
Object.keys(RELATION_TYPES) as [RelationType, ...RelationType[]],
|
||||
),
|
||||
}),
|
||||
});
|
||||
@ -78,17 +74,13 @@ const StyledInputsContainer = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const RELATION_TYPE_OPTIONS = Object.entries(RELATION_TYPES)
|
||||
.filter(
|
||||
([value]) =>
|
||||
RelationDefinitionType.ONE_TO_ONE !== value &&
|
||||
RelationDefinitionType.MANY_TO_MANY !== value,
|
||||
)
|
||||
.map(([value, { label, Icon }]) => ({
|
||||
const RELATION_TYPE_OPTIONS = Object.entries(RELATION_TYPES).map(
|
||||
([value, { label, Icon }]) => ({
|
||||
label,
|
||||
value: value as RelationType,
|
||||
Icon,
|
||||
}));
|
||||
}),
|
||||
);
|
||||
|
||||
export const SettingsDataModelFieldRelationForm = ({
|
||||
fieldMetadataItem,
|
||||
@ -170,7 +162,7 @@ export const SettingsDataModelFieldRelationForm = ({
|
||||
</StyledSelectsContainer>
|
||||
<StyledInputsLabel>
|
||||
Field on{' '}
|
||||
{selectedRelationType === RelationDefinitionType.MANY_TO_ONE
|
||||
{selectedRelationType === RelationType.MANY_TO_ONE
|
||||
? selectedObjectMetadataItem?.labelSingular
|
||||
: selectedObjectMetadataItem?.labelPlural}
|
||||
</StyledInputsLabel>
|
||||
|
||||
@ -17,8 +17,8 @@ import {
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinition,
|
||||
RelationDefinitionType,
|
||||
Relation,
|
||||
RelationType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
type SettingsDataModelFieldRelationSettingsFormCardProps = {
|
||||
fieldMetadataItem: Pick<FieldMetadataItem, 'icon' | 'label' | 'type'> &
|
||||
@ -78,13 +78,16 @@ export const SettingsDataModelFieldRelationSettingsFormCard = ({
|
||||
|
||||
if (!relationObjectMetadataItem) return null;
|
||||
|
||||
const relationType = watchFormValue('relation.type', initialRelationType);
|
||||
const relationType: RelationType = watchFormValue(
|
||||
'relation.type',
|
||||
initialRelationType,
|
||||
);
|
||||
const relationTypeConfig = RELATION_TYPES[relationType];
|
||||
|
||||
const oppositeRelationType =
|
||||
relationType === RelationDefinitionType.MANY_TO_ONE
|
||||
? RelationDefinitionType.ONE_TO_MANY
|
||||
: RelationDefinitionType.MANY_TO_ONE;
|
||||
relationType === RelationType.MANY_TO_ONE
|
||||
? RelationType.ONE_TO_MANY
|
||||
: RelationType.MANY_TO_ONE;
|
||||
|
||||
return (
|
||||
<SettingsDataModelPreviewFormCard
|
||||
@ -93,16 +96,15 @@ export const SettingsDataModelFieldRelationSettingsFormCard = ({
|
||||
<StyledFieldPreviewCard
|
||||
fieldMetadataItem={{
|
||||
...fieldMetadataItem,
|
||||
relationDefinition: {
|
||||
direction: relationType,
|
||||
} as RelationDefinition,
|
||||
relation: {
|
||||
type: relationType,
|
||||
} as Relation,
|
||||
}}
|
||||
shrink
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
relationObjectMetadataItem={relationObjectMetadataItem}
|
||||
pluralizeLabel={
|
||||
watchFormValue('relation.type') ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
watchFormValue('relation.type') === RelationType.MANY_TO_ONE
|
||||
}
|
||||
/>
|
||||
<StyledRelationImage
|
||||
@ -124,16 +126,15 @@ export const SettingsDataModelFieldRelationSettingsFormCard = ({
|
||||
initialRelationFieldMetadataItem.label,
|
||||
) || 'Field name',
|
||||
type: FieldMetadataType.RELATION,
|
||||
relationDefinition: {
|
||||
direction: oppositeRelationType,
|
||||
} as RelationDefinition,
|
||||
relation: {
|
||||
type: oppositeRelationType,
|
||||
} as Relation,
|
||||
}}
|
||||
shrink
|
||||
objectMetadataItem={relationObjectMetadataItem}
|
||||
relationObjectMetadataItem={objectMetadataItem}
|
||||
pluralizeLabel={
|
||||
watchFormValue('relation.type') !==
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
watchFormValue('relation.type') !== RelationType.MANY_TO_ONE
|
||||
}
|
||||
/>
|
||||
</StyledPreviewContent>
|
||||
|
||||
@ -6,13 +6,13 @@ import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { isObjectMetadataAvailableForRelation } from '@/object-metadata/utils/isObjectMetadataAvailableForRelation';
|
||||
import { SettingsDataModelFieldPreviewCardProps } from '@/settings/data-model/fields/preview/components/SettingsDataModelFieldPreviewCard';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useRelationSettingsFormInitialValues = ({
|
||||
fieldMetadataItem,
|
||||
objectMetadataItem,
|
||||
}: {
|
||||
fieldMetadataItem?: Pick<FieldMetadataItem, 'type' | 'relationDefinition'>;
|
||||
fieldMetadataItem?: Pick<FieldMetadataItem, 'type' | 'relation'>;
|
||||
objectMetadataItem?: SettingsDataModelFieldPreviewCardProps['objectMetadataItem'];
|
||||
}) => {
|
||||
const { activeObjectMetadataItems } = useFilteredObjectMetadataItems();
|
||||
@ -49,7 +49,7 @@ export const useRelationSettingsFormInitialValues = ({
|
||||
]);
|
||||
|
||||
const initialRelationType =
|
||||
relationTypeFromFieldMetadata ?? RelationDefinitionType.ONE_TO_MANY;
|
||||
relationTypeFromFieldMetadata ?? RelationType.ONE_TO_MANY;
|
||||
|
||||
return {
|
||||
disableFieldEdition:
|
||||
@ -57,10 +57,7 @@ export const useRelationSettingsFormInitialValues = ({
|
||||
disableRelationEdition: !!relationFieldMetadataItem,
|
||||
initialRelationFieldMetadataItem: relationFieldMetadataItem ?? {
|
||||
icon: initialRelationObjectMetadataItem.icon ?? 'IconUsers',
|
||||
label: [
|
||||
RelationDefinitionType.MANY_TO_MANY,
|
||||
RelationDefinitionType.MANY_TO_ONE,
|
||||
].includes(initialRelationType)
|
||||
label: [RelationType.MANY_TO_ONE].includes(initialRelationType)
|
||||
? initialRelationObjectMetadataItem.labelPlural
|
||||
: initialRelationObjectMetadataItem.labelSingular,
|
||||
},
|
||||
|
||||
@ -26,7 +26,7 @@ export type SettingsDataModelFieldPreviewProps = {
|
||||
| 'defaultValue'
|
||||
| 'options'
|
||||
| 'settings'
|
||||
| 'relationDefinition'
|
||||
| 'relation'
|
||||
> & {
|
||||
id?: string;
|
||||
name?: string;
|
||||
@ -102,7 +102,7 @@ export const SettingsDataModelFieldPreview = ({
|
||||
fieldMetadataItem.name || `${fieldMetadataItem.type}-new-field`;
|
||||
const recordId =
|
||||
previewRecord?.id ??
|
||||
`${objectMetadataItem.nameSingular}-${fieldName}-${fieldMetadataItem.relationDefinition?.direction}-${relationObjectMetadataItem?.nameSingular}-preview`;
|
||||
`${objectMetadataItem.nameSingular}-${fieldName}-${fieldMetadataItem.relation?.type}-${relationObjectMetadataItem?.nameSingular}-preview`;
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -146,7 +146,7 @@ export const SettingsDataModelFieldPreview = ({
|
||||
relationObjectMetadataItem?.nameSingular,
|
||||
options: fieldMetadataItem.options ?? [],
|
||||
settings: fieldMetadataItem.settings,
|
||||
relationType: fieldMetadataItem.relationDefinition?.direction,
|
||||
relationType: fieldMetadataItem.relation?.type,
|
||||
},
|
||||
defaultValue: fieldMetadataItem.defaultValue,
|
||||
},
|
||||
|
||||
@ -8,15 +8,12 @@ import { getFieldPreviewValue } from '@/settings/data-model/fields/preview/utils
|
||||
import { getMultiSelectFieldPreviewValue } from '@/settings/data-model/fields/preview/utils/getMultiSelectFieldPreviewValue';
|
||||
import { getPhonesFieldPreviewValue } from '@/settings/data-model/fields/preview/utils/getPhonesFieldPreviewValue';
|
||||
import { getSelectFieldPreviewValue } from '@/settings/data-model/fields/preview/utils/getSelectFieldPreviewValue';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
type UseFieldPreviewParams = {
|
||||
fieldMetadataItem: Pick<
|
||||
FieldMetadataItem,
|
||||
'type' | 'options' | 'defaultValue' | 'relationDefinition'
|
||||
'type' | 'options' | 'defaultValue' | 'relation'
|
||||
>;
|
||||
relationObjectMetadataItem?: ObjectMetadataItem;
|
||||
skip?: boolean;
|
||||
@ -46,8 +43,7 @@ export const useFieldPreviewValue = ({
|
||||
case FieldMetadataType.CURRENCY:
|
||||
return getCurrencyFieldPreviewValue({ fieldMetadataItem });
|
||||
case FieldMetadataType.RELATION:
|
||||
return fieldMetadataItem.relationDefinition?.direction ===
|
||||
RelationDefinitionType.MANY_TO_ONE
|
||||
return fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE
|
||||
? relationFieldPreviewValue
|
||||
: [relationFieldPreviewValue];
|
||||
case FieldMetadataType.SELECT:
|
||||
|
||||
@ -43,25 +43,22 @@ export const SettingsDataModelOverviewEffect = ({
|
||||
|
||||
for (const field of object.fields) {
|
||||
if (
|
||||
isDefined(field.relationDefinition) &&
|
||||
isDefined(field.relation) &&
|
||||
isDefined(
|
||||
items.find(
|
||||
(x) =>
|
||||
x.id === field.relationDefinition?.targetObjectMetadata.id,
|
||||
(x) => x.id === field.relation?.targetObjectMetadata.id,
|
||||
),
|
||||
)
|
||||
) {
|
||||
const sourceObj =
|
||||
field.relationDefinition?.sourceObjectMetadata.namePlural;
|
||||
const targetObj =
|
||||
field.relationDefinition?.targetObjectMetadata.namePlural;
|
||||
const sourceObj = field.relation?.sourceObjectMetadata.namePlural;
|
||||
const targetObj = field.relation?.targetObjectMetadata.namePlural;
|
||||
|
||||
edges.push({
|
||||
id: `${sourceObj}-${targetObj}`,
|
||||
source: object.namePlural,
|
||||
sourceHandle: `${field.id}-right`,
|
||||
target: field.relationDefinition.targetObjectMetadata.namePlural,
|
||||
targetHandle: `${field.relationDefinition.targetObjectMetadata}-left`,
|
||||
target: field.relation.targetObjectMetadata.namePlural,
|
||||
targetHandle: `${field.relation.targetObjectMetadata}-left`,
|
||||
type: 'smoothstep',
|
||||
style: {
|
||||
strokeWidth: 1,
|
||||
@ -71,8 +68,8 @@ export const SettingsDataModelOverviewEffect = ({
|
||||
markerStart: 'marker',
|
||||
data: {
|
||||
sourceField: field.id,
|
||||
targetField: field.relationDefinition.targetFieldMetadata.id,
|
||||
relation: field.relationDefinition.direction,
|
||||
targetField: field.relation.targetFieldMetadata.id,
|
||||
relation: field.relation.type,
|
||||
sourceObject: sourceObj,
|
||||
targetObject: targetObj,
|
||||
},
|
||||
|
||||
@ -5,8 +5,8 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
type ObjectFieldRowProps = {
|
||||
field: FieldMetadataItem;
|
||||
@ -30,7 +30,7 @@ export const ObjectFieldRow = ({ field }: ObjectFieldRowProps) => {
|
||||
const { getIcon } = useIcons();
|
||||
const theme = useTheme();
|
||||
|
||||
const relatedObjectId = field.relationDefinition?.targetObjectMetadata.id;
|
||||
const relatedObjectId = field.relation?.targetObjectMetadata.id;
|
||||
|
||||
const relatedObject = objectMetadataItems.find(
|
||||
(x) => x.id === relatedObjectId,
|
||||
@ -44,32 +44,28 @@ export const ObjectFieldRow = ({ field }: ObjectFieldRowProps) => {
|
||||
<StyledFieldName>{relatedObject?.labelPlural ?? ''}</StyledFieldName>
|
||||
<Handle
|
||||
type={
|
||||
field.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
field.relation?.type === RelationType.ONE_TO_MANY
|
||||
? 'source'
|
||||
: 'target'
|
||||
}
|
||||
position={Position.Right}
|
||||
id={`${field.id}-right`}
|
||||
className={
|
||||
field.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
field.relation?.type === RelationType.ONE_TO_MANY
|
||||
? 'right-handle source-handle'
|
||||
: 'right-handle target-handle'
|
||||
}
|
||||
/>
|
||||
<Handle
|
||||
type={
|
||||
field.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
field.relation?.type === RelationType.ONE_TO_MANY
|
||||
? 'source'
|
||||
: 'target'
|
||||
}
|
||||
position={Position.Left}
|
||||
id={`${field.id}-left`}
|
||||
className={
|
||||
field.relationDefinition?.direction ===
|
||||
RelationDefinitionType.ONE_TO_MANY
|
||||
field.relation?.type === RelationType.ONE_TO_MANY
|
||||
? 'left-handle source-handle'
|
||||
: 'left-handle target-handle'
|
||||
}
|
||||
|
||||
@ -19,16 +19,16 @@ import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useMemo } from 'react';
|
||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { IconMinus, IconPlus, useIcons } from 'twenty-ui/display';
|
||||
import { LightIconButton } from 'twenty-ui/input';
|
||||
import { UndecoratedLink } from 'twenty-ui/navigation';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||
import { SettingsObjectDetailTableItem } from '~/pages/settings/data-model/types/SettingsObjectDetailTableItem';
|
||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||
import { RELATION_TYPES } from '../../constants/RelationTypes';
|
||||
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { IconMinus, IconPlus, useIcons } from 'twenty-ui/display';
|
||||
import { LightIconButton } from 'twenty-ui/input';
|
||||
import { UndecoratedLink } from 'twenty-ui/navigation';
|
||||
|
||||
type SettingsObjectFieldItemTableRowProps = {
|
||||
settingsObjectDetailTableItem: SettingsObjectDetailTableItem;
|
||||
@ -240,8 +240,7 @@ export const SettingsObjectFieldItemTableRow = ({
|
||||
<SettingsObjectFieldDataType
|
||||
Icon={RelationIcon}
|
||||
label={
|
||||
relationType === RelationDefinitionType.MANY_TO_ONE ||
|
||||
relationType === RelationDefinitionType.ONE_TO_ONE
|
||||
relationType === RelationType.MANY_TO_ONE
|
||||
? relationObjectMetadataItem?.labelSingular
|
||||
: relationObjectMetadataItem?.labelPlural
|
||||
}
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
|
||||
export type RelationType = RelationDefinitionType;
|
||||
@ -1,10 +1,7 @@
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
||||
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
[
|
||||
@ -67,7 +64,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
type: FieldMetadataType.RELATION,
|
||||
metadata: {
|
||||
fieldName: 'favorites',
|
||||
relationType: RelationDefinitionType.ONE_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
relationObjectMetadataNameSingular: '',
|
||||
relationObjectMetadataNamePlural: '',
|
||||
objectMetadataNameSingular: 'company',
|
||||
@ -101,7 +98,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
type: FieldMetadataType.RELATION,
|
||||
metadata: {
|
||||
fieldName: 'accountOwner',
|
||||
relationType: RelationDefinitionType.MANY_TO_ONE,
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
relationObjectMetadataNameSingular: 'workspaceMember',
|
||||
relationObjectMetadataNamePlural: 'workspaceMembers',
|
||||
objectMetadataNameSingular: 'company',
|
||||
@ -118,7 +115,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
type: FieldMetadataType.RELATION,
|
||||
metadata: {
|
||||
fieldName: 'people',
|
||||
relationType: RelationDefinitionType.ONE_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
relationObjectMetadataNameSingular: '',
|
||||
relationObjectMetadataNamePlural: '',
|
||||
objectMetadataNameSingular: 'company',
|
||||
@ -135,7 +132,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
type: FieldMetadataType.RELATION,
|
||||
metadata: {
|
||||
fieldName: 'attachments',
|
||||
relationType: RelationDefinitionType.ONE_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
relationObjectMetadataNameSingular: '',
|
||||
relationObjectMetadataNamePlural: '',
|
||||
objectMetadataNameSingular: 'company',
|
||||
@ -203,7 +200,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
type: FieldMetadataType.RELATION,
|
||||
metadata: {
|
||||
fieldName: 'opportunities',
|
||||
relationType: RelationDefinitionType.ONE_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
relationObjectMetadataNameSingular: '',
|
||||
relationObjectMetadataNamePlural: '',
|
||||
objectMetadataNameSingular: 'company',
|
||||
@ -237,7 +234,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COLUMN_DEFINITIONS = (
|
||||
type: FieldMetadataType.RELATION,
|
||||
metadata: {
|
||||
fieldName: 'activityTargets',
|
||||
relationType: RelationDefinitionType.ONE_TO_MANY,
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
relationObjectMetadataNameSingular: '',
|
||||
relationObjectMetadataNamePlural: '',
|
||||
objectMetadataNameSingular: 'company',
|
||||
|
||||
@ -87,12 +87,11 @@ export const useViewFromQueryParams = () => {
|
||||
if (!fieldMetadataItem) return null;
|
||||
|
||||
const relationObjectMetadataNameSingular =
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata
|
||||
fieldMetadataItem.relation?.targetObjectMetadata
|
||||
?.nameSingular;
|
||||
|
||||
const relationObjectMetadataNamePlural =
|
||||
fieldMetadataItem.relationDefinition?.targetObjectMetadata
|
||||
?.namePlural;
|
||||
fieldMetadataItem.relation?.targetObjectMetadata?.namePlural;
|
||||
|
||||
const relationObjectMetadataItem =
|
||||
relationObjectMetadataNameSingular
|
||||
|
||||
@ -2,9 +2,11 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { formatFieldMetadataItemAsFieldDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsFieldDefinition';
|
||||
import { FormMultiSelectFieldInput } from '@/object-record/record-field/form-types/components/FormMultiSelectFieldInput';
|
||||
import { FieldMultiSelectValue } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { isFieldRelation } from '@/object-record/record-field/types/guards/isFieldRelation';
|
||||
import { shouldDisplayFormField } from '@/workflow/workflow-steps/workflow-actions/utils/shouldDisplayFormField';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { shouldDisplayFormField } from '@/workflow/workflow-steps/workflow-actions/utils/shouldDisplayFormField';
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const WorkflowFieldsMultiSelect = ({
|
||||
label,
|
||||
@ -50,12 +52,22 @@ export const WorkflowFieldsMultiSelect = ({
|
||||
testId="workflow-fields-multi-select"
|
||||
label={label}
|
||||
defaultValue={defaultFields}
|
||||
options={inlineFieldDefinitions.map((field) => ({
|
||||
label: field.label,
|
||||
value: field.metadata.fieldName,
|
||||
icon: getIcon(field.iconName),
|
||||
color: 'gray',
|
||||
}))}
|
||||
options={inlineFieldDefinitions.map((field) => {
|
||||
const isFieldRelationManyToOne =
|
||||
isFieldRelation(field) &&
|
||||
field.metadata.relationType === RelationType.MANY_TO_ONE;
|
||||
|
||||
const value = isFieldRelationManyToOne
|
||||
? `${field.metadata.fieldName}Id`
|
||||
: field.metadata.fieldName;
|
||||
|
||||
return {
|
||||
label: field.label,
|
||||
value,
|
||||
icon: getIcon(field.iconName),
|
||||
color: 'gray',
|
||||
};
|
||||
})}
|
||||
onChange={handleFieldsChange}
|
||||
placeholder={placeholder}
|
||||
readonly={readonly}
|
||||
|
||||
Reference in New Issue
Block a user