mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-24 20:42:05 +03:00
fix: remove usage of probability field (#5877)
- fixes #5735 --------- Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
This commit is contained in:
parent
c0f6f52669
commit
364caf0fdf
@ -333,7 +333,6 @@ export enum FieldMetadataType {
|
||||
Numeric = 'NUMERIC',
|
||||
Phone = 'PHONE',
|
||||
Position = 'POSITION',
|
||||
Probability = 'PROBABILITY',
|
||||
Rating = 'RATING',
|
||||
RawJson = 'RAW_JSON',
|
||||
Relation = 'RELATION',
|
||||
|
@ -246,7 +246,6 @@ export enum FieldMetadataType {
|
||||
Numeric = 'NUMERIC',
|
||||
Phone = 'PHONE',
|
||||
Position = 'POSITION',
|
||||
Probability = 'PROBABILITY',
|
||||
Rating = 'RATING',
|
||||
RawJson = 'RAW_JSON',
|
||||
Relation = 'RELATION',
|
||||
|
@ -39,11 +39,6 @@ export const formatFieldMetadataItemsAsFilterDefinitions = ({
|
||||
return acc;
|
||||
}
|
||||
|
||||
// Todo: remove once Rating fieldtype is implemented
|
||||
if (field.name === 'probability') {
|
||||
return acc;
|
||||
}
|
||||
|
||||
return [...acc, formatFieldMetadataItemAsFilterDefinition({ field })];
|
||||
}, [] as FilterDefinition[]);
|
||||
|
||||
|
@ -82,7 +82,7 @@ export const usePersistField = () => {
|
||||
isFieldBoolean(fieldDefinition) &&
|
||||
isFieldBooleanValue(valueToPersist);
|
||||
|
||||
const fieldIsProbability =
|
||||
const fieldIsRating =
|
||||
isFieldRating(fieldDefinition) && isFieldRatingValue(valueToPersist);
|
||||
|
||||
const fieldIsNumber =
|
||||
@ -119,7 +119,7 @@ export const usePersistField = () => {
|
||||
fieldIsText ||
|
||||
fieldIsBoolean ||
|
||||
fieldIsEmail ||
|
||||
fieldIsProbability ||
|
||||
fieldIsRating ||
|
||||
fieldIsNumber ||
|
||||
fieldIsDateTime ||
|
||||
fieldIsDate ||
|
||||
|
@ -51,19 +51,17 @@ type AssertFieldMetadataFunction = <
|
||||
? FieldNumberMetadata
|
||||
: E extends 'PHONE'
|
||||
? FieldPhoneMetadata
|
||||
: E extends 'PROBABILITY'
|
||||
? FieldRatingMetadata
|
||||
: E extends 'RELATION'
|
||||
? FieldRelationMetadata
|
||||
: E extends 'TEXT'
|
||||
? FieldTextMetadata
|
||||
: E extends 'UUID'
|
||||
? FieldUuidMetadata
|
||||
: E extends 'ADDRESS'
|
||||
? FieldAddressMetadata
|
||||
: E extends 'RAW_JSON'
|
||||
? FieldRawJsonMetadata
|
||||
: never,
|
||||
: E extends 'RELATION'
|
||||
? FieldRelationMetadata
|
||||
: E extends 'TEXT'
|
||||
? FieldTextMetadata
|
||||
: E extends 'UUID'
|
||||
? FieldUuidMetadata
|
||||
: E extends 'ADDRESS'
|
||||
? FieldAddressMetadata
|
||||
: E extends 'RAW_JSON'
|
||||
? FieldRawJsonMetadata
|
||||
: never,
|
||||
>(
|
||||
fieldType: E,
|
||||
fieldTypeGuard: (
|
||||
|
@ -102,11 +102,6 @@ export const SETTINGS_FIELD_TYPE_CONFIGS = {
|
||||
Icon: IconPhone,
|
||||
defaultValue: '+1234-567-890',
|
||||
},
|
||||
[FieldMetadataType.Probability]: {
|
||||
label: 'Rating',
|
||||
Icon: IconTwentyStar,
|
||||
defaultValue: '3',
|
||||
},
|
||||
[FieldMetadataType.Rating]: {
|
||||
label: 'Rating',
|
||||
Icon: IconTwentyStar,
|
||||
|
@ -161,7 +161,7 @@ export const SettingsObjectNewFieldStep2 = () => {
|
||||
// FieldMetadataType.FullName,
|
||||
FieldMetadataType.Link,
|
||||
FieldMetadataType.Numeric,
|
||||
FieldMetadataType.Probability,
|
||||
// FieldMetadataType.Probability,
|
||||
// FieldMetadataType.Uuid,
|
||||
// FieldMetadataType.Phone,
|
||||
] as const
|
||||
|
@ -145,13 +145,6 @@ const fieldNumericMock = {
|
||||
defaultValue: null,
|
||||
};
|
||||
|
||||
const fieldProbabilityMock = {
|
||||
name: 'fieldProbability',
|
||||
type: FieldMetadataType.PROBABILITY,
|
||||
isNullable: true,
|
||||
defaultValue: null,
|
||||
};
|
||||
|
||||
const fieldFullNameMock = {
|
||||
name: 'fieldFullName',
|
||||
type: FieldMetadataType.FULL_NAME,
|
||||
@ -206,7 +199,6 @@ export const fields = [
|
||||
fieldBooleanMock,
|
||||
fieldNumberMock,
|
||||
fieldNumericMock,
|
||||
fieldProbabilityMock,
|
||||
fieldLinkMock,
|
||||
fieldLinksMock,
|
||||
fieldCurrencyMock,
|
||||
|
@ -73,7 +73,6 @@ export class TypeMapperService {
|
||||
),
|
||||
],
|
||||
[FieldMetadataType.NUMERIC, BigFloatScalarType],
|
||||
[FieldMetadataType.PROBABILITY, GraphQLFloat],
|
||||
[FieldMetadataType.POSITION, PositionScalarType],
|
||||
[FieldMetadataType.RAW_JSON, RawJSONScalar],
|
||||
]);
|
||||
@ -109,7 +108,6 @@ export class TypeMapperService {
|
||||
),
|
||||
],
|
||||
[FieldMetadataType.NUMERIC, BigFloatFilterType],
|
||||
[FieldMetadataType.PROBABILITY, FloatFilterType],
|
||||
[FieldMetadataType.POSITION, FloatFilterType],
|
||||
[FieldMetadataType.RAW_JSON, RawJsonFilterType],
|
||||
]);
|
||||
@ -130,7 +128,6 @@ export class TypeMapperService {
|
||||
[FieldMetadataType.BOOLEAN, OrderByDirectionType],
|
||||
[FieldMetadataType.NUMBER, OrderByDirectionType],
|
||||
[FieldMetadataType.NUMERIC, OrderByDirectionType],
|
||||
[FieldMetadataType.PROBABILITY, OrderByDirectionType],
|
||||
[FieldMetadataType.RATING, OrderByDirectionType],
|
||||
[FieldMetadataType.SELECT, OrderByDirectionType],
|
||||
[FieldMetadataType.MULTI_SELECT, OrderByDirectionType],
|
||||
|
@ -55,9 +55,6 @@ describe('computeSchemaComponents', () => {
|
||||
fieldNumeric: {
|
||||
type: 'number',
|
||||
},
|
||||
fieldProbability: {
|
||||
type: 'number',
|
||||
},
|
||||
fieldLink: {
|
||||
properties: {
|
||||
label: { type: 'string' },
|
||||
|
@ -35,7 +35,6 @@ const getFieldProperties = (type: FieldMetadataType): Property => {
|
||||
case FieldMetadataType.NUMBER:
|
||||
return { type: 'integer' };
|
||||
case FieldMetadataType.NUMERIC:
|
||||
case FieldMetadataType.PROBABILITY:
|
||||
case FieldMetadataType.RATING:
|
||||
case FieldMetadataType.POSITION:
|
||||
return { type: 'number' };
|
||||
|
@ -31,7 +31,6 @@ export enum FieldMetadataType {
|
||||
BOOLEAN = 'BOOLEAN',
|
||||
NUMBER = 'NUMBER',
|
||||
NUMERIC = 'NUMERIC',
|
||||
PROBABILITY = 'PROBABILITY',
|
||||
LINK = 'LINK',
|
||||
LINKS = 'LINKS',
|
||||
CURRENCY = 'CURRENCY',
|
||||
|
@ -35,7 +35,6 @@ type FieldMetadataDefaultValueMapping = {
|
||||
[FieldMetadataType.NUMBER]: FieldMetadataDefaultValueNumber;
|
||||
[FieldMetadataType.POSITION]: FieldMetadataDefaultValueNumber;
|
||||
[FieldMetadataType.NUMERIC]: FieldMetadataDefaultValueString;
|
||||
[FieldMetadataType.PROBABILITY]: FieldMetadataDefaultValueNumber;
|
||||
[FieldMetadataType.LINK]: FieldMetadataDefaultValueLink;
|
||||
[FieldMetadataType.LINKS]: FieldMetadataDefaultValueLinks;
|
||||
[FieldMetadataType.CURRENCY]: FieldMetadataDefaultValueCurrency;
|
||||
|
@ -78,18 +78,6 @@ describe('validateDefaultValueForType', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should validate number default value for PROBABILITY type', () => {
|
||||
expect(
|
||||
validateDefaultValueForType(FieldMetadataType.PROBABILITY, 0.5).isValid,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for invalid number default value for PROBABILITY type', () => {
|
||||
expect(
|
||||
validateDefaultValueForType(FieldMetadataType.PROBABILITY, '50%').isValid,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should validate boolean default value for BOOLEAN type', () => {
|
||||
expect(
|
||||
validateDefaultValueForType(FieldMetadataType.BOOLEAN, true).isValid,
|
||||
|
@ -41,7 +41,6 @@ export const defaultValueValidatorsMap = {
|
||||
[FieldMetadataType.BOOLEAN]: [FieldMetadataDefaultValueBoolean],
|
||||
[FieldMetadataType.NUMBER]: [FieldMetadataDefaultValueNumber],
|
||||
[FieldMetadataType.NUMERIC]: [FieldMetadataDefaultValueString],
|
||||
[FieldMetadataType.PROBABILITY]: [FieldMetadataDefaultValueNumber],
|
||||
[FieldMetadataType.LINK]: [FieldMetadataDefaultValueLink],
|
||||
[FieldMetadataType.CURRENCY]: [FieldMetadataDefaultValueCurrency],
|
||||
[FieldMetadataType.FULL_NAME]: [FieldMetadataDefaultValueFullName],
|
||||
|
@ -25,7 +25,6 @@ export type BasicFieldMetadataType =
|
||||
| FieldMetadataType.EMAIL
|
||||
| FieldMetadataType.NUMERIC
|
||||
| FieldMetadataType.NUMBER
|
||||
| FieldMetadataType.PROBABILITY
|
||||
| FieldMetadataType.BOOLEAN
|
||||
| FieldMetadataType.POSITION
|
||||
| FieldMetadataType.DATE_TIME
|
||||
|
@ -22,7 +22,6 @@ export const fieldMetadataTypeToColumnType = <Type extends FieldMetadataType>(
|
||||
case FieldMetadataType.NUMERIC:
|
||||
return 'numeric';
|
||||
case FieldMetadataType.NUMBER:
|
||||
case FieldMetadataType.PROBABILITY:
|
||||
case FieldMetadataType.POSITION:
|
||||
return 'float';
|
||||
case FieldMetadataType.BOOLEAN:
|
||||
|
@ -72,10 +72,6 @@ export class WorkspaceMigrationFactory {
|
||||
[FieldMetadataType.NUMBER, { factory: this.basicColumnActionFactory }],
|
||||
[FieldMetadataType.POSITION, { factory: this.basicColumnActionFactory }],
|
||||
[FieldMetadataType.RAW_JSON, { factory: this.basicColumnActionFactory }],
|
||||
[
|
||||
FieldMetadataType.PROBABILITY,
|
||||
{ factory: this.basicColumnActionFactory },
|
||||
],
|
||||
[FieldMetadataType.BOOLEAN, { factory: this.basicColumnActionFactory }],
|
||||
[FieldMetadataType.DATE_TIME, { factory: this.basicColumnActionFactory }],
|
||||
[FieldMetadataType.DATE, { factory: this.basicColumnActionFactory }],
|
||||
|
Loading…
Reference in New Issue
Block a user