-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve Settings supported field types validation (#4496)
* refactor: improve Settings supported field types validation Related to: #4084, #4295 * fix: fix wrong import
- Loading branch information
1 parent
a560746
commit 1639b2a
Showing
11 changed files
with
95 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 22 additions & 13 deletions
35
.../modules/settings/data-model/fields/forms/components/SettingsDataModelFieldTypeSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/twenty-front/src/modules/settings/data-model/types/SettingsSupportedFieldType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
export type SettingsSupportedFieldType = Exclude< | ||
FieldMetadataType, | ||
FieldMetadataType.Position | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/twenty-front/src/modules/settings/data-model/utils/getSettingsFieldTypeConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SETTINGS_FIELD_TYPE_CONFIGS } from '@/settings/data-model/constants/SettingsFieldTypeConfigs'; | ||
import { isFieldTypeSupportedInSettings } from '@/settings/data-model/utils/isFieldTypeSupportedInSettings'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
export const getSettingsFieldTypeConfig = (fieldType: FieldMetadataType) => | ||
isFieldTypeSupportedInSettings(fieldType) | ||
? SETTINGS_FIELD_TYPE_CONFIGS[fieldType] | ||
: undefined; |
8 changes: 8 additions & 0 deletions
8
...ages/twenty-front/src/modules/settings/data-model/utils/isFieldTypeSupportedInSettings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SETTINGS_FIELD_TYPE_CONFIGS } from '@/settings/data-model/constants/SettingsFieldTypeConfigs'; | ||
import { SettingsSupportedFieldType } from '@/settings/data-model/types/SettingsSupportedFieldType'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
export const isFieldTypeSupportedInSettings = ( | ||
fieldType: FieldMetadataType, | ||
): fieldType is SettingsSupportedFieldType => | ||
fieldType in SETTINGS_FIELD_TYPE_CONFIGS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters