Skip to content

Commit 83afb7b

Browse files
thaisguigonWeiko
authored andcommitted
feat: add feature flag to activate Links field creation (#5535)
Related issue: #3607
1 parent 06133f8 commit 83afb7b

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export type FeatureFlagKey =
44
| 'IS_EVENT_OBJECT_ENABLED'
55
| 'IS_AIRTABLE_INTEGRATION_ENABLED'
66
| 'IS_POSTGRESQL_INTEGRATION_ENABLED'
7-
| 'IS_STRIPE_INTEGRATION_ENABLED';
7+
| 'IS_STRIPE_INTEGRATION_ENABLED'
8+
| 'IS_LINKS_FIELD_ENABLED';

packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx

+16-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import { Section } from '@/ui/layout/section/components/Section';
3131
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
3232
import { View } from '@/views/types/View';
3333
import { ViewType } from '@/views/types/ViewType';
34+
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
3435
import { FieldMetadataType } from '~/generated-metadata/graphql';
36+
import { isDefined } from '~/utils/isDefined';
3537
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
3638

3739
type SettingsDataModelNewFieldFormValues = z.infer<
@@ -109,6 +111,8 @@ export const SettingsObjectNewFieldStep2 = () => {
109111
const { createOneRelationMetadataItem: createOneRelationMetadata } =
110112
useCreateOneRelationMetadataItem();
111113

114+
const isLinksFieldEnabled = useIsFeatureEnabled('IS_LINKS_FIELD_ENABLED');
115+
112116
if (!activeObjectMetadataItem) return null;
113117

114118
const canSave =
@@ -263,16 +267,18 @@ export const SettingsObjectNewFieldStep2 = () => {
263267
}
264268
};
265269

266-
const excludedFieldTypes: SettingsSupportedFieldType[] = [
267-
FieldMetadataType.Email,
268-
FieldMetadataType.FullName,
269-
FieldMetadataType.Link,
270-
FieldMetadataType.Links,
271-
FieldMetadataType.Numeric,
272-
FieldMetadataType.Probability,
273-
FieldMetadataType.Uuid,
274-
FieldMetadataType.Phone,
275-
];
270+
const excludedFieldTypes: SettingsSupportedFieldType[] = (
271+
[
272+
FieldMetadataType.Email,
273+
FieldMetadataType.FullName,
274+
FieldMetadataType.Link,
275+
isLinksFieldEnabled ? undefined : FieldMetadataType.Links,
276+
FieldMetadataType.Numeric,
277+
FieldMetadataType.Probability,
278+
FieldMetadataType.Uuid,
279+
FieldMetadataType.Phone,
280+
] as const
281+
).filter(isDefined);
276282

277283
return (
278284
// eslint-disable-next-line react/jsx-props-no-spreading

packages/twenty-front/src/testing/mock-data/users.ts

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export const mockDefaultWorkspace: Workspace = {
5050
value: true,
5151
workspaceId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6w',
5252
},
53+
{
54+
id: '1492de61-5018-4368-8923-4f1eeaf988c7',
55+
key: 'IS_LINKS_FIELD_ENABLED',
56+
value: true,
57+
workspaceId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6w',
58+
},
5359
],
5460
createdAt: '2023-04-26T10:23:42.33625+00:00',
5561
updatedAt: '2023-04-26T10:23:42.33625+00:00',

packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ export const seedFeatureFlags = async (
4545
workspaceId: workspaceId,
4646
value: true,
4747
},
48+
{
49+
key: FeatureFlagKeys.IsLinksFieldEnabled,
50+
workspaceId: workspaceId,
51+
value: true,
52+
},
4853
])
4954
.execute();
5055
};

packages/twenty-server/src/engine/core-modules/feature-flag/feature-flag.entity.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export enum FeatureFlagKeys {
2222
IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
2323
IsStripeIntegrationEnabled = 'IS_STRIPE_INTEGRATION_ENABLED',
2424
IsGmailSyncV2Enabled = 'IS_GMAIL_SYNC_V2_ENABLED',
25+
IsLinksFieldEnabled = 'IS_LINKS_FIELD_ENABLED',
2526
}
2627

2728
@Entity({ name: 'featureFlag', schema: 'core' })

packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class AddStandardIdCommand extends CommandRunner {
5959
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
6060
IS_STRIPE_INTEGRATION_ENABLED: false,
6161
IS_GMAIL_SYNC_V2_ENABLED: true,
62+
IS_LINKS_FIELD_ENABLED: true,
6263
},
6364
);
6465
const standardFieldMetadataCollection = this.standardFieldFactory.create(
@@ -74,6 +75,7 @@ export class AddStandardIdCommand extends CommandRunner {
7475
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
7576
IS_STRIPE_INTEGRATION_ENABLED: false,
7677
IS_GMAIL_SYNC_V2_ENABLED: true,
78+
IS_LINKS_FIELD_ENABLED: true,
7779
},
7880
);
7981

0 commit comments

Comments
 (0)