fieldmetadatatype + featurelfag creation (#13021)
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -463,6 +463,7 @@ export type CreateFieldInput = {
|
||||
isSystem?: InputMaybe<Scalars['Boolean']>;
|
||||
isUnique?: InputMaybe<Scalars['Boolean']>;
|
||||
label: Scalars['String'];
|
||||
morphRelationsCreationPayload?: InputMaybe<Array<Scalars['JSON']>>;
|
||||
name: Scalars['String'];
|
||||
objectMetadataId: Scalars['String'];
|
||||
options?: InputMaybe<Scalars['JSON']>;
|
||||
@ -679,6 +680,7 @@ export enum FeatureFlagKey {
|
||||
IS_AI_ENABLED = 'IS_AI_ENABLED',
|
||||
IS_IMAP_ENABLED = 'IS_IMAP_ENABLED',
|
||||
IS_JSON_FILTER_ENABLED = 'IS_JSON_FILTER_ENABLED',
|
||||
IS_MORPH_RELATION_ENABLED = 'IS_MORPH_RELATION_ENABLED',
|
||||
IS_POSTGRESQL_INTEGRATION_ENABLED = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
|
||||
IS_RELATION_CONNECT_ENABLED = 'IS_RELATION_CONNECT_ENABLED',
|
||||
IS_STRIPE_INTEGRATION_ENABLED = 'IS_STRIPE_INTEGRATION_ENABLED',
|
||||
@ -747,6 +749,7 @@ export enum FieldMetadataType {
|
||||
EMAILS = 'EMAILS',
|
||||
FULL_NAME = 'FULL_NAME',
|
||||
LINKS = 'LINKS',
|
||||
MORPH_RELATION = 'MORPH_RELATION',
|
||||
MULTI_SELECT = 'MULTI_SELECT',
|
||||
NUMBER = 'NUMBER',
|
||||
NUMERIC = 'NUMERIC',
|
||||
|
||||
@ -459,6 +459,7 @@ export type CreateFieldInput = {
|
||||
isSystem?: InputMaybe<Scalars['Boolean']>;
|
||||
isUnique?: InputMaybe<Scalars['Boolean']>;
|
||||
label: Scalars['String'];
|
||||
morphRelationsCreationPayload?: InputMaybe<Array<Scalars['JSON']>>;
|
||||
name: Scalars['String'];
|
||||
objectMetadataId: Scalars['String'];
|
||||
options?: InputMaybe<Scalars['JSON']>;
|
||||
@ -643,6 +644,7 @@ export enum FeatureFlagKey {
|
||||
IS_AI_ENABLED = 'IS_AI_ENABLED',
|
||||
IS_IMAP_ENABLED = 'IS_IMAP_ENABLED',
|
||||
IS_JSON_FILTER_ENABLED = 'IS_JSON_FILTER_ENABLED',
|
||||
IS_MORPH_RELATION_ENABLED = 'IS_MORPH_RELATION_ENABLED',
|
||||
IS_POSTGRESQL_INTEGRATION_ENABLED = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
|
||||
IS_RELATION_CONNECT_ENABLED = 'IS_RELATION_CONNECT_ENABLED',
|
||||
IS_STRIPE_INTEGRATION_ENABLED = 'IS_STRIPE_INTEGRATION_ENABLED',
|
||||
@ -711,6 +713,7 @@ export enum FieldMetadataType {
|
||||
EMAILS = 'EMAILS',
|
||||
FULL_NAME = 'FULL_NAME',
|
||||
LINKS = 'LINKS',
|
||||
MORPH_RELATION = 'MORPH_RELATION',
|
||||
MULTI_SELECT = 'MULTI_SELECT',
|
||||
NUMBER = 'NUMBER',
|
||||
NUMERIC = 'NUMERIC',
|
||||
|
||||
@ -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
|
||||
|
||||
@ -12,6 +12,7 @@ export const DEFAULT_ICONS_BY_FIELD_TYPE: Record<FieldMetadataType, string> = {
|
||||
[FieldMetadataType.RATING]: 'IconStar',
|
||||
[FieldMetadataType.RAW_JSON]: 'IconBraces',
|
||||
[FieldMetadataType.RELATION]: 'IconRelationOneToMany',
|
||||
[FieldMetadataType.MORPH_RELATION]: 'IconRelationOneToMany',
|
||||
[FieldMetadataType.SELECT]: 'IconTag',
|
||||
[FieldMetadataType.TEXT]: 'IconTypography',
|
||||
[FieldMetadataType.UUID]: 'IconId',
|
||||
|
||||
Reference in New Issue
Block a user