Allow workflow field update when custom (#11619)

- Allow workflow field update when custom
- Also handle the case where object name is not defined in actions
This commit is contained in:
Thomas Trompette
2025-04-17 15:01:18 +02:00
committed by GitHub
parent 1401f80081
commit d2881bb4a2
9 changed files with 155 additions and 199 deletions

View File

@ -18,5 +18,6 @@ export const useIsFieldValueReadOnly = ({
fieldName: metadata.fieldName,
fieldType: type,
isRecordReadOnly,
isCustom: metadata.isCustom,
});
};

View File

@ -1,7 +1,7 @@
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { FieldMetadata } from './FieldMetadata';
import { IconComponent } from 'twenty-ui/display';
import { FieldMetadata } from './FieldMetadata';
export type FieldDefinition<T extends FieldMetadata> = {
fieldMetadataId: string;

View File

@ -1,46 +1,42 @@
import { RATING_VALUES } from '@/object-record/record-field/meta-types/constants/RatingValues';
import { ZodHelperLiteral } from '@/object-record/record-field/types/ZodHelperLiteral';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { ConnectedAccountProvider } from 'twenty-shared/types';
import { ThemeColor } from 'twenty-ui/theme';
import * as z from 'zod';
import { RelationDefinitionType } from '~/generated-metadata/graphql';
import { CurrencyCode } from './CurrencyCode';
import { ConnectedAccountProvider } from 'twenty-shared/types';
import { ThemeColor } from 'twenty-ui/theme';
export type FieldUuidMetadata = {
objectMetadataNameSingular?: string;
type BaseFieldMetadata = {
fieldName: string;
objectMetadataNameSingular?: string;
isCustom?: boolean;
};
export type FieldUuidMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldBooleanMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldBooleanMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldTextMetadata = {
objectMetadataNameSingular?: string;
export type FieldTextMetadata = BaseFieldMetadata & {
placeHolder: string;
fieldName: string;
settings?: {
displayedMaxRows?: number;
};
};
export type FieldDateTimeMetadata = {
objectMetadataNameSingular?: string;
export type FieldDateTimeMetadata = BaseFieldMetadata & {
placeHolder: string;
fieldName: string;
settings?: {
displayAsRelativeDate?: boolean;
};
};
export type FieldDateMetadata = {
objectMetadataNameSingular?: string;
export type FieldDateMetadata = BaseFieldMetadata & {
placeHolder: string;
fieldName: string;
settings?: {
displayAsRelativeDate?: boolean;
};
@ -48,9 +44,7 @@ export type FieldDateMetadata = {
export type FieldNumberVariant = 'number' | 'percentage';
export type FieldNumberMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldNumberMetadata = BaseFieldMetadata & {
placeHolder: string;
isPositive?: boolean;
settings?: {
@ -59,95 +53,67 @@ export type FieldNumberMetadata = {
};
};
export type FieldLinkMetadata = {
objectMetadataNameSingular?: string;
export type FieldLinkMetadata = BaseFieldMetadata & {
placeHolder: string;
fieldName: string;
settings?: null;
};
export type FieldLinksMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldLinksMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldCurrencyMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldCurrencyMetadata = BaseFieldMetadata & {
placeHolder: string;
isPositive?: boolean;
settings?: null;
};
export type FieldFullNameMetadata = {
objectMetadataNameSingular?: string;
placeHolder: string;
fieldName: string;
settings?: null;
};
export type FieldEmailMetadata = {
objectMetadataNameSingular?: string;
placeHolder: string;
fieldName: string;
settings?: null;
};
export type FieldEmailsMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
settings?: null;
};
export type FieldPhoneMetadata = {
objectMetadataNameSingular?: string;
placeHolder: string;
fieldName: string;
settings?: null;
};
export type FieldRatingMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
settings?: null;
};
export type FieldAddressMetadata = {
objectMetadataNameSingular?: string;
placeHolder: string;
fieldName: string;
settings?: null;
};
export type FieldRawJsonMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldFullNameMetadata = BaseFieldMetadata & {
placeHolder: string;
settings?: null;
};
export type FieldRichTextV2Metadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldEmailMetadata = BaseFieldMetadata & {
placeHolder: string;
settings?: null;
};
export type FieldRichTextMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldEmailsMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldPositionMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldPhoneMetadata = BaseFieldMetadata & {
placeHolder: string;
settings?: null;
};
export type FieldRelationMetadata = {
fieldName: string;
objectMetadataNameSingular?: string;
export type FieldRatingMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldAddressMetadata = BaseFieldMetadata & {
placeHolder: string;
settings?: null;
};
export type FieldRawJsonMetadata = BaseFieldMetadata & {
placeHolder: string;
settings?: null;
};
export type FieldRichTextV2Metadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldRichTextMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldPositionMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldRelationMetadata = BaseFieldMetadata & {
relationFieldMetadataId: string;
relationObjectMetadataNamePlural: string;
relationObjectMetadataNameSingular: string;
@ -157,43 +123,31 @@ export type FieldRelationMetadata = {
settings?: null;
};
export type FieldSelectMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldSelectMetadata = BaseFieldMetadata & {
options: { label: string; color: ThemeColor; value: string }[];
isNullable: boolean;
settings?: null;
};
export type FieldMultiSelectMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldMultiSelectMetadata = BaseFieldMetadata & {
options: { label: string; color: ThemeColor; value: string }[];
settings?: null;
};
export type FieldActorMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldActorMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldArrayMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldArrayMetadata = BaseFieldMetadata & {
values: { label: string; value: string }[];
settings?: null;
};
export type FieldPhonesMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldPhonesMetadata = BaseFieldMetadata & {
settings?: null;
};
export type FieldTsVectorMetadata = {
objectMetadataNameSingular?: string;
fieldName: string;
export type FieldTsVectorMetadata = BaseFieldMetadata & {
settings?: null;
};

View File

@ -11,6 +11,7 @@ type isFieldValueReadOnlyParams = {
fieldName?: string;
fieldType?: FieldMetadataType;
isRecordReadOnly?: boolean;
isCustom?: boolean;
};
export const isFieldValueReadOnly = ({
@ -18,6 +19,7 @@ export const isFieldValueReadOnly = ({
fieldName,
fieldType,
isRecordReadOnly = false,
isCustom = false,
}: isFieldValueReadOnlyParams) => {
if (isRecordReadOnly) {
return true;
@ -40,7 +42,8 @@ export const isFieldValueReadOnly = ({
if (
objectNameSingular === CoreObjectNameSingular.Workflow &&
fieldName !== 'name'
fieldName !== 'name' &&
!isCustom
) {
return true;
}