fix: display current object name in morph relation picker after rename (#17209)
**Summary** Issue #16963: When an object is renamed, the morph relation picker still shows the old name. **Root cause** The picker used searchRecord.objectNameSingular from the GraphQL search response, which can be stale after a rename. The search record stores the object name at query time, not the current metadata. **Solution** - Updated SingleRecordPickerMenuItem: - Added useObjectMetadataItems to access current object metadata. - Look up the current object metadata by morphItem.objectMetadataId. - Use labelSingular (or nameSingular as fallback) instead of searchRecord.objectNameSingular for display. - Updated MultipleRecordPickerMenuItemContent: - Use objectMetadataItem.labelSingular (already available as a prop) instead of searchRecord.objectNameSingular. --------- Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
This commit is contained in:
+2
-2
@@ -8,7 +8,7 @@ exports[`fromCreateFieldInputToFlatFieldMetadatasToCreate MORPH_RELATION test su
|
||||
"message": "Morph relation creation payloads must have the same relation type",
|
||||
"userFriendlyMessage": {
|
||||
"id": Any<String>,
|
||||
"message": "Morph relation creation payloads must have the same relation type",
|
||||
"message": "An error occurred.",
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -46,7 +46,7 @@ exports[`fromCreateFieldInputToFlatFieldMetadatasToCreate MORPH_RELATION test su
|
||||
"message": "Morph relation creation payloads must have only relation to the same object metadata",
|
||||
"userFriendlyMessage": {
|
||||
"id": Any<String>,
|
||||
"message": "Morph relation creation payloads must only contain relation to the same object metadata",
|
||||
"message": "An error occurred.",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
+4
-3
@@ -2,6 +2,7 @@ import { msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'class-validator';
|
||||
import { type RelationCreationPayload } from 'twenty-shared/types';
|
||||
|
||||
import { STANDARD_ERROR_MESSAGE } from 'src/engine/api/common/common-query-runners/errors/standard-error-message.constant';
|
||||
import { FieldMetadataExceptionCode } from 'src/engine/metadata-modules/field-metadata/field-metadata.exception';
|
||||
import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import {
|
||||
@@ -58,7 +59,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message:
|
||||
'Morph relation creation payloads must have the same relation type',
|
||||
userFriendlyMessage: msg`Morph relation creation payloads must have the same relation type`,
|
||||
userFriendlyMessage: STANDARD_ERROR_MESSAGE,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -79,7 +80,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message:
|
||||
'Morph relation creation payloads must not target source object metadata',
|
||||
userFriendlyMessage: msg`Morph relation creation payloads must only contain relation to other object metadata`,
|
||||
userFriendlyMessage: STANDARD_ERROR_MESSAGE,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -95,7 +96,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message:
|
||||
'Morph relation creation payloads must have only relation to the same object metadata',
|
||||
userFriendlyMessage: msg`Morph relation creation payloads must only contain relation to the same object metadata`,
|
||||
userFriendlyMessage: STANDARD_ERROR_MESSAGE,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user