fieldmetadatatype + featurelfag creation (#13021)
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -56,7 +56,8 @@ export const generateEmptyFieldValue = ({
|
||||
case FieldMetadataType.BOOLEAN: {
|
||||
return true;
|
||||
}
|
||||
case FieldMetadataType.RELATION: {
|
||||
case FieldMetadataType.RELATION:
|
||||
case FieldMetadataType.MORPH_RELATION: {
|
||||
if (fieldMetadataItem.relation?.type === RelationType.MANY_TO_ONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -122,6 +122,11 @@ export const SETTINGS_NON_COMPOSITE_FIELD_TYPE_CONFIGS: SettingsNonCompositeFiel
|
||||
Icon: IllustrationIconOneToMany,
|
||||
category: 'Relation',
|
||||
} as const satisfies SettingsFieldTypeConfig<FieldRelationValue<any>>,
|
||||
[FieldMetadataType.MORPH_RELATION]: {
|
||||
label: 'Morph Relation',
|
||||
Icon: IllustrationIconOneToMany,
|
||||
category: 'Relation',
|
||||
} as const satisfies SettingsFieldTypeConfig<FieldRelationValue<any>>,
|
||||
[FieldMetadataType.RATING]: {
|
||||
label: 'Rating',
|
||||
Icon: IllustrationIconStar,
|
||||
|
||||
@ -11,6 +11,7 @@ import { FieldType } from '@/settings/data-model/types/FieldType';
|
||||
import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { t } from '@lingui/core/macro';
|
||||
@ -20,6 +21,7 @@ import { Controller, useFormContext } from 'react-hook-form';
|
||||
import { H2Title, IconSearch } from 'twenty-ui/display';
|
||||
import { UndecoratedLink } from 'twenty-ui/navigation';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
import { SettingsDataModelFieldTypeFormValues } from '~/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldSelect';
|
||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||
|
||||
@ -102,7 +104,9 @@ export const SettingsObjectNewFieldSelector = ({
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const isMorphRelationEnabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IS_MORPH_RELATION_ENABLED,
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{' '}
|
||||
@ -131,6 +135,12 @@ export const SettingsObjectNewFieldSelector = ({
|
||||
<StyledContainer>
|
||||
{fieldTypeConfigs
|
||||
.filter(([, config]) => config.category === category)
|
||||
.filter(([key]) => {
|
||||
return (
|
||||
key !== FieldMetadataType.MORPH_RELATION ||
|
||||
isMorphRelationEnabled
|
||||
);
|
||||
})
|
||||
.map(([key, config]) => (
|
||||
<StyledCardContainer key={key}>
|
||||
<UndecoratedLink
|
||||
|
||||
Reference in New Issue
Block a user