-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
- Loading branch information
1 parent
846da39
commit 9d1ecb5
Showing
11 changed files
with
101 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; |
10 changes: 10 additions & 0 deletions
10
...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,10 @@ | ||
import { | ||
SETTINGS_FIELD_TYPE_CONFIGS, | ||
SettingsSupportedFieldTypes, | ||
} from '@/settings/data-model/constants/SettingsFieldTypeConfigs'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
export const isFieldTypeSupportedInSettings = ( | ||
fieldType: FieldMetadataType, | ||
): fieldType is SettingsSupportedFieldTypes => | ||
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