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:
@ -18,5 +18,6 @@ export const useIsFieldValueReadOnly = ({
|
|||||||
fieldName: metadata.fieldName,
|
fieldName: metadata.fieldName,
|
||||||
fieldType: type,
|
fieldType: type,
|
||||||
isRecordReadOnly,
|
isRecordReadOnly,
|
||||||
|
isCustom: metadata.isCustom,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
|
||||||
import { FieldMetadata } from './FieldMetadata';
|
|
||||||
import { IconComponent } from 'twenty-ui/display';
|
import { IconComponent } from 'twenty-ui/display';
|
||||||
|
import { FieldMetadata } from './FieldMetadata';
|
||||||
|
|
||||||
export type FieldDefinition<T extends FieldMetadata> = {
|
export type FieldDefinition<T extends FieldMetadata> = {
|
||||||
fieldMetadataId: string;
|
fieldMetadataId: string;
|
||||||
|
|||||||
@ -1,46 +1,42 @@
|
|||||||
import { RATING_VALUES } from '@/object-record/record-field/meta-types/constants/RatingValues';
|
import { RATING_VALUES } from '@/object-record/record-field/meta-types/constants/RatingValues';
|
||||||
import { ZodHelperLiteral } from '@/object-record/record-field/types/ZodHelperLiteral';
|
import { ZodHelperLiteral } from '@/object-record/record-field/types/ZodHelperLiteral';
|
||||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
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 * as z from 'zod';
|
||||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||||
import { CurrencyCode } from './CurrencyCode';
|
import { CurrencyCode } from './CurrencyCode';
|
||||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
|
||||||
import { ThemeColor } from 'twenty-ui/theme';
|
|
||||||
|
|
||||||
export type FieldUuidMetadata = {
|
type BaseFieldMetadata = {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
|
objectMetadataNameSingular?: string;
|
||||||
|
isCustom?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FieldUuidMetadata = BaseFieldMetadata & {
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldBooleanMetadata = {
|
export type FieldBooleanMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldTextMetadata = {
|
export type FieldTextMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
fieldName: string;
|
|
||||||
settings?: {
|
settings?: {
|
||||||
displayedMaxRows?: number;
|
displayedMaxRows?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldDateTimeMetadata = {
|
export type FieldDateTimeMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
fieldName: string;
|
|
||||||
settings?: {
|
settings?: {
|
||||||
displayAsRelativeDate?: boolean;
|
displayAsRelativeDate?: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldDateMetadata = {
|
export type FieldDateMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
fieldName: string;
|
|
||||||
settings?: {
|
settings?: {
|
||||||
displayAsRelativeDate?: boolean;
|
displayAsRelativeDate?: boolean;
|
||||||
};
|
};
|
||||||
@ -48,9 +44,7 @@ export type FieldDateMetadata = {
|
|||||||
|
|
||||||
export type FieldNumberVariant = 'number' | 'percentage';
|
export type FieldNumberVariant = 'number' | 'percentage';
|
||||||
|
|
||||||
export type FieldNumberMetadata = {
|
export type FieldNumberMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
isPositive?: boolean;
|
isPositive?: boolean;
|
||||||
settings?: {
|
settings?: {
|
||||||
@ -59,95 +53,67 @@ export type FieldNumberMetadata = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldLinkMetadata = {
|
export type FieldLinkMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldLinksMetadata = {
|
export type FieldLinksMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldCurrencyMetadata = {
|
export type FieldCurrencyMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
isPositive?: boolean;
|
isPositive?: boolean;
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldFullNameMetadata = {
|
export type FieldFullNameMetadata = BaseFieldMetadata & {
|
||||||
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;
|
|
||||||
placeHolder: string;
|
placeHolder: string;
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldRichTextV2Metadata = {
|
export type FieldEmailMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
placeHolder: string;
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldRichTextMetadata = {
|
export type FieldEmailsMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldPositionMetadata = {
|
export type FieldPhoneMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
placeHolder: string;
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldRelationMetadata = {
|
export type FieldRatingMetadata = BaseFieldMetadata & {
|
||||||
fieldName: string;
|
settings?: null;
|
||||||
objectMetadataNameSingular?: string;
|
};
|
||||||
|
|
||||||
|
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;
|
relationFieldMetadataId: string;
|
||||||
relationObjectMetadataNamePlural: string;
|
relationObjectMetadataNamePlural: string;
|
||||||
relationObjectMetadataNameSingular: string;
|
relationObjectMetadataNameSingular: string;
|
||||||
@ -157,43 +123,31 @@ export type FieldRelationMetadata = {
|
|||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldSelectMetadata = {
|
export type FieldSelectMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
options: { label: string; color: ThemeColor; value: string }[];
|
options: { label: string; color: ThemeColor; value: string }[];
|
||||||
isNullable: boolean;
|
isNullable: boolean;
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldMultiSelectMetadata = {
|
export type FieldMultiSelectMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
options: { label: string; color: ThemeColor; value: string }[];
|
options: { label: string; color: ThemeColor; value: string }[];
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldActorMetadata = {
|
export type FieldActorMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldArrayMetadata = {
|
export type FieldArrayMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
values: { label: string; value: string }[];
|
values: { label: string; value: string }[];
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldPhonesMetadata = {
|
export type FieldPhonesMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FieldTsVectorMetadata = {
|
export type FieldTsVectorMetadata = BaseFieldMetadata & {
|
||||||
objectMetadataNameSingular?: string;
|
|
||||||
fieldName: string;
|
|
||||||
settings?: null;
|
settings?: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ type isFieldValueReadOnlyParams = {
|
|||||||
fieldName?: string;
|
fieldName?: string;
|
||||||
fieldType?: FieldMetadataType;
|
fieldType?: FieldMetadataType;
|
||||||
isRecordReadOnly?: boolean;
|
isRecordReadOnly?: boolean;
|
||||||
|
isCustom?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isFieldValueReadOnly = ({
|
export const isFieldValueReadOnly = ({
|
||||||
@ -18,6 +19,7 @@ export const isFieldValueReadOnly = ({
|
|||||||
fieldName,
|
fieldName,
|
||||||
fieldType,
|
fieldType,
|
||||||
isRecordReadOnly = false,
|
isRecordReadOnly = false,
|
||||||
|
isCustom = false,
|
||||||
}: isFieldValueReadOnlyParams) => {
|
}: isFieldValueReadOnlyParams) => {
|
||||||
if (isRecordReadOnly) {
|
if (isRecordReadOnly) {
|
||||||
return true;
|
return true;
|
||||||
@ -40,7 +42,8 @@ export const isFieldValueReadOnly = ({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
objectNameSingular === CoreObjectNameSingular.Workflow &&
|
objectNameSingular === CoreObjectNameSingular.Workflow &&
|
||||||
fieldName !== 'name'
|
fieldName !== 'name' &&
|
||||||
|
!isCustom
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import { mapArrayToObject } from '~/utils/array/mapArrayToObject';
|
|||||||
import { moveArrayItem } from '~/utils/array/moveArrayItem';
|
import { moveArrayItem } from '~/utils/array/moveArrayItem';
|
||||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||||
|
|
||||||
import { ViewField } from '../types/ViewField';
|
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
|
import { ViewField } from '../types/ViewField';
|
||||||
|
|
||||||
export const mapViewFieldsToColumnDefinitions = ({
|
export const mapViewFieldsToColumnDefinitions = ({
|
||||||
columnDefinitions,
|
columnDefinitions,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||||
import { formatFieldMetadataItemAsFieldDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsFieldDefinition';
|
import { formatFieldMetadataItemAsFieldDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsFieldDefinition';
|
||||||
import { FormFieldInput } from '@/object-record/record-field/components/FormFieldInput';
|
import { FormFieldInput } from '@/object-record/record-field/components/FormFieldInput';
|
||||||
import { Select } from '@/ui/input/components/Select';
|
import { Select } from '@/ui/input/components/Select';
|
||||||
@ -13,11 +13,11 @@ import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/
|
|||||||
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
|
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||||
|
import { SelectOption } from 'twenty-ui/input';
|
||||||
import { JsonValue } from 'type-fest';
|
import { JsonValue } from 'type-fest';
|
||||||
import { useDebouncedCallback } from 'use-debounce';
|
import { useDebouncedCallback } from 'use-debounce';
|
||||||
import { FieldMetadataType } from '~/generated/graphql';
|
import { FieldMetadataType } from '~/generated/graphql';
|
||||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
|
||||||
import { SelectOption } from 'twenty-ui/input';
|
|
||||||
|
|
||||||
type WorkflowEditActionCreateRecordProps = {
|
type WorkflowEditActionCreateRecordProps = {
|
||||||
action: WorkflowCreateRecordAction;
|
action: WorkflowCreateRecordAction;
|
||||||
@ -78,17 +78,19 @@ export const WorkflowEditActionCreateRecord = ({
|
|||||||
|
|
||||||
const objectNameSingular = formData.objectName;
|
const objectNameSingular = formData.objectName;
|
||||||
|
|
||||||
const { objectMetadataItem } = useObjectMetadataItem({
|
const { objectMetadataItems } = useObjectMetadataItems();
|
||||||
objectNameSingular,
|
|
||||||
});
|
const objectMetadataItem = objectMetadataItems.find(
|
||||||
|
(item) => item.nameSingular === objectNameSingular,
|
||||||
|
);
|
||||||
|
|
||||||
const { view: indexView } = useViewOrDefaultViewFromPrefetchedViews({
|
const { view: indexView } = useViewOrDefaultViewFromPrefetchedViews({
|
||||||
objectMetadataItemId: objectMetadataItem.id ?? '',
|
objectMetadataItemId: objectMetadataItem?.id ?? '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const viewFields = indexView?.viewFields ?? [];
|
const viewFields = indexView?.viewFields ?? [];
|
||||||
|
|
||||||
const inlineFieldMetadataItems = objectMetadataItem.fields
|
const inlineFieldMetadataItems = objectMetadataItem?.fields
|
||||||
.filter(
|
.filter(
|
||||||
(fieldMetadataItem) =>
|
(fieldMetadataItem) =>
|
||||||
fieldMetadataItem.type !== FieldMetadataType.RELATION &&
|
fieldMetadataItem.type !== FieldMetadataType.RELATION &&
|
||||||
@ -106,15 +108,16 @@ export const WorkflowEditActionCreateRecord = ({
|
|||||||
})
|
})
|
||||||
.sort(sortByViewFieldPosition);
|
.sort(sortByViewFieldPosition);
|
||||||
|
|
||||||
const inlineFieldDefinitions = inlineFieldMetadataItems.map(
|
const inlineFieldDefinitions = isDefined(objectMetadataItem)
|
||||||
(fieldMetadataItem) =>
|
? inlineFieldMetadataItems?.map((fieldMetadataItem) =>
|
||||||
formatFieldMetadataItemAsFieldDefinition({
|
formatFieldMetadataItemAsFieldDefinition({
|
||||||
field: fieldMetadataItem,
|
field: fieldMetadataItem,
|
||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
showLabel: true,
|
showLabel: true,
|
||||||
labelWidth: 90,
|
labelWidth: 90,
|
||||||
}),
|
}),
|
||||||
);
|
)
|
||||||
|
: [];
|
||||||
|
|
||||||
const handleFieldChange = (
|
const handleFieldChange = (
|
||||||
fieldName: keyof CreateRecordFormData,
|
fieldName: keyof CreateRecordFormData,
|
||||||
@ -205,7 +208,7 @@ export const WorkflowEditActionCreateRecord = ({
|
|||||||
|
|
||||||
<HorizontalSeparator noMargin />
|
<HorizontalSeparator noMargin />
|
||||||
|
|
||||||
{inlineFieldDefinitions.map((field) => {
|
{inlineFieldDefinitions?.map((field) => {
|
||||||
const currentValue = formData[field.metadata.fieldName] as JsonValue;
|
const currentValue = formData[field.metadata.fieldName] as JsonValue;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -11,10 +11,10 @@ import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-ac
|
|||||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||||
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import { JsonValue } from 'type-fest';
|
|
||||||
import { useDebouncedCallback } from 'use-debounce';
|
|
||||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||||
import { SelectOption } from 'twenty-ui/input';
|
import { SelectOption } from 'twenty-ui/input';
|
||||||
|
import { JsonValue } from 'type-fest';
|
||||||
|
import { useDebouncedCallback } from 'use-debounce';
|
||||||
|
|
||||||
type WorkflowEditActionDeleteRecordProps = {
|
type WorkflowEditActionDeleteRecordProps = {
|
||||||
action: WorkflowDeleteRecordAction;
|
action: WorkflowDeleteRecordAction;
|
||||||
@ -68,14 +68,9 @@ export const WorkflowEditActionDeleteRecord = ({
|
|||||||
saveAction(newFormData);
|
saveAction(newFormData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedObjectMetadataItemNameSingular = formData.objectName;
|
const objectNameSingular = activeObjectMetadataItems.find(
|
||||||
|
(item) => item.nameSingular === formData.objectName,
|
||||||
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
)?.nameSingular;
|
||||||
(item) => item.nameSingular === selectedObjectMetadataItemNameSingular,
|
|
||||||
);
|
|
||||||
if (!isDefined(selectedObjectMetadataItem)) {
|
|
||||||
throw new Error('Should have found the metadata item');
|
|
||||||
}
|
|
||||||
|
|
||||||
const saveAction = useDebouncedCallback(
|
const saveAction = useDebouncedCallback(
|
||||||
async (formData: DeleteRecordFormData) => {
|
async (formData: DeleteRecordFormData) => {
|
||||||
@ -156,17 +151,19 @@ export const WorkflowEditActionDeleteRecord = ({
|
|||||||
|
|
||||||
<HorizontalSeparator noMargin />
|
<HorizontalSeparator noMargin />
|
||||||
|
|
||||||
<FormSingleRecordPicker
|
{isDefined(objectNameSingular) && (
|
||||||
label="Record"
|
<FormSingleRecordPicker
|
||||||
onChange={(objectRecordId) =>
|
label="Record"
|
||||||
handleFieldChange('objectRecordId', objectRecordId)
|
onChange={(objectRecordId) =>
|
||||||
}
|
handleFieldChange('objectRecordId', objectRecordId)
|
||||||
objectNameSingular={formData.objectName}
|
}
|
||||||
defaultValue={formData.objectRecordId}
|
objectNameSingular={objectNameSingular}
|
||||||
testId="workflow-edit-action-record-delete-object-record-id"
|
defaultValue={formData.objectRecordId}
|
||||||
disabled={isFormDisabled}
|
testId="workflow-edit-action-record-delete-object-record-id"
|
||||||
VariablePicker={WorkflowVariablePicker}
|
disabled={isFormDisabled}
|
||||||
/>
|
VariablePicker={WorkflowVariablePicker}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</WorkflowStepBody>
|
</WorkflowStepBody>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -10,9 +10,9 @@ import { useActionHeaderTypeOrThrow } from '@/workflow/workflow-steps/workflow-a
|
|||||||
import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-actions/hooks/useActionIconColorOrThrow';
|
import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-actions/hooks/useActionIconColorOrThrow';
|
||||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import { useDebouncedCallback } from 'use-debounce';
|
|
||||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||||
import { SelectOption } from 'twenty-ui/input';
|
import { SelectOption } from 'twenty-ui/input';
|
||||||
|
import { useDebouncedCallback } from 'use-debounce';
|
||||||
|
|
||||||
type WorkflowEditActionFindRecordsProps = {
|
type WorkflowEditActionFindRecordsProps = {
|
||||||
action: WorkflowFindRecordsAction;
|
action: WorkflowFindRecordsAction;
|
||||||
@ -52,14 +52,10 @@ export const WorkflowEditActionFindRecords = ({
|
|||||||
});
|
});
|
||||||
const isFormDisabled = actionOptions.readonly;
|
const isFormDisabled = actionOptions.readonly;
|
||||||
|
|
||||||
const selectedObjectMetadataItemNameSingular = formData.objectName;
|
const selectedObjectMetadataItemNameSingular =
|
||||||
|
activeObjectMetadataItems.find(
|
||||||
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
(item) => item.nameSingular === formData.objectName,
|
||||||
(item) => item.nameSingular === selectedObjectMetadataItemNameSingular,
|
)?.nameSingular ?? '';
|
||||||
);
|
|
||||||
if (!isDefined(selectedObjectMetadataItem)) {
|
|
||||||
throw new Error('Should have found the metadata item');
|
|
||||||
}
|
|
||||||
|
|
||||||
const saveAction = useDebouncedCallback(
|
const saveAction = useDebouncedCallback(
|
||||||
async (formData: FindRecordsFormData) => {
|
async (formData: FindRecordsFormData) => {
|
||||||
@ -119,7 +115,7 @@ export const WorkflowEditActionFindRecords = ({
|
|||||||
label="Object"
|
label="Object"
|
||||||
fullWidth
|
fullWidth
|
||||||
disabled={isFormDisabled}
|
disabled={isFormDisabled}
|
||||||
value={formData.objectName}
|
value={selectedObjectMetadataItemNameSingular}
|
||||||
emptyOption={{ label: 'Select an option', value: '' }}
|
emptyOption={{ label: 'Select an option', value: '' }}
|
||||||
options={availableMetadata}
|
options={availableMetadata}
|
||||||
onChange={(objectName) => {
|
onChange={(objectName) => {
|
||||||
|
|||||||
@ -14,11 +14,11 @@ import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-ac
|
|||||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||||
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
|
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||||
|
import { SelectOption } from 'twenty-ui/input';
|
||||||
import { JsonValue } from 'type-fest';
|
import { JsonValue } from 'type-fest';
|
||||||
import { useDebouncedCallback } from 'use-debounce';
|
import { useDebouncedCallback } from 'use-debounce';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
|
||||||
import { SelectOption } from 'twenty-ui/input';
|
|
||||||
|
|
||||||
type WorkflowEditActionUpdateRecordProps = {
|
type WorkflowEditActionUpdateRecordProps = {
|
||||||
action: WorkflowUpdateRecordAction;
|
action: WorkflowUpdateRecordAction;
|
||||||
@ -94,16 +94,13 @@ export const WorkflowEditActionUpdateRecord = ({
|
|||||||
saveAction(newFormData);
|
saveAction(newFormData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedObjectMetadataItemNameSingular = formData.objectName;
|
|
||||||
|
|
||||||
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
||||||
(item) => item.nameSingular === selectedObjectMetadataItemNameSingular,
|
(item) => item.nameSingular === formData.objectName,
|
||||||
);
|
);
|
||||||
if (!isDefined(selectedObjectMetadataItem)) {
|
|
||||||
throw new Error('Should have found the metadata item');
|
|
||||||
}
|
|
||||||
|
|
||||||
const inlineFieldMetadataItems = selectedObjectMetadataItem.fields
|
const objectNameSingular = selectedObjectMetadataItem?.nameSingular;
|
||||||
|
|
||||||
|
const inlineFieldMetadataItems = selectedObjectMetadataItem?.fields
|
||||||
.filter(
|
.filter(
|
||||||
(fieldMetadataItem) =>
|
(fieldMetadataItem) =>
|
||||||
!fieldMetadataItem.isSystem &&
|
!fieldMetadataItem.isSystem &&
|
||||||
@ -114,15 +111,16 @@ export const WorkflowEditActionUpdateRecord = ({
|
|||||||
fieldMetadataItemA.name.localeCompare(fieldMetadataItemB.name),
|
fieldMetadataItemA.name.localeCompare(fieldMetadataItemB.name),
|
||||||
);
|
);
|
||||||
|
|
||||||
const inlineFieldDefinitions = inlineFieldMetadataItems.map(
|
const inlineFieldDefinitions = isDefined(selectedObjectMetadataItem)
|
||||||
(fieldMetadataItem) =>
|
? inlineFieldMetadataItems?.map((fieldMetadataItem) =>
|
||||||
formatFieldMetadataItemAsFieldDefinition({
|
formatFieldMetadataItemAsFieldDefinition({
|
||||||
field: fieldMetadataItem,
|
field: fieldMetadataItem,
|
||||||
objectMetadataItem: selectedObjectMetadataItem,
|
objectMetadataItem: selectedObjectMetadataItem,
|
||||||
showLabel: true,
|
showLabel: true,
|
||||||
labelWidth: 90,
|
labelWidth: 90,
|
||||||
}),
|
}),
|
||||||
);
|
)
|
||||||
|
: [];
|
||||||
|
|
||||||
const saveAction = useDebouncedCallback(
|
const saveAction = useDebouncedCallback(
|
||||||
async (formData: UpdateRecordFormData) => {
|
async (formData: UpdateRecordFormData) => {
|
||||||
@ -209,39 +207,43 @@ export const WorkflowEditActionUpdateRecord = ({
|
|||||||
|
|
||||||
<HorizontalSeparator noMargin />
|
<HorizontalSeparator noMargin />
|
||||||
|
|
||||||
<FormSingleRecordPicker
|
{isDefined(objectNameSingular) && (
|
||||||
testId="workflow-edit-action-record-update-object-record-id"
|
<FormSingleRecordPicker
|
||||||
label="Record"
|
testId="workflow-edit-action-record-update-object-record-id"
|
||||||
onChange={(objectRecordId) =>
|
label="Record"
|
||||||
handleFieldChange('objectRecordId', objectRecordId)
|
onChange={(objectRecordId) =>
|
||||||
}
|
handleFieldChange('objectRecordId', objectRecordId)
|
||||||
objectNameSingular={formData.objectName}
|
}
|
||||||
defaultValue={formData.objectRecordId}
|
objectNameSingular={objectNameSingular}
|
||||||
disabled={isFormDisabled}
|
defaultValue={formData.objectRecordId}
|
||||||
VariablePicker={WorkflowVariablePicker}
|
disabled={isFormDisabled}
|
||||||
/>
|
VariablePicker={WorkflowVariablePicker}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<FormMultiSelectFieldInput
|
{isDefined(inlineFieldDefinitions) && (
|
||||||
testId="workflow-edit-action-record-update-fields-to-update"
|
<FormMultiSelectFieldInput
|
||||||
label="Fields to update"
|
testId="workflow-edit-action-record-update-fields-to-update"
|
||||||
defaultValue={formData.fieldsToUpdate}
|
label="Fields to update"
|
||||||
options={inlineFieldDefinitions.map((field) => ({
|
defaultValue={formData.fieldsToUpdate}
|
||||||
label: field.label,
|
options={inlineFieldDefinitions.map((field) => ({
|
||||||
value: field.metadata.fieldName,
|
label: field.label,
|
||||||
icon: getIcon(field.iconName),
|
value: field.metadata.fieldName,
|
||||||
color: 'gray',
|
icon: getIcon(field.iconName),
|
||||||
}))}
|
color: 'gray',
|
||||||
onChange={(fieldsToUpdate) =>
|
}))}
|
||||||
handleFieldChange('fieldsToUpdate', fieldsToUpdate)
|
onChange={(fieldsToUpdate) =>
|
||||||
}
|
handleFieldChange('fieldsToUpdate', fieldsToUpdate)
|
||||||
placeholder="Select fields to update"
|
}
|
||||||
readonly={isFormDisabled}
|
placeholder="Select fields to update"
|
||||||
/>
|
readonly={isFormDisabled}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<HorizontalSeparator noMargin />
|
<HorizontalSeparator noMargin />
|
||||||
|
|
||||||
{formData.fieldsToUpdate.map((fieldName) => {
|
{formData.fieldsToUpdate.map((fieldName) => {
|
||||||
const fieldDefinition = inlineFieldDefinitions.find(
|
const fieldDefinition = inlineFieldDefinitions?.find(
|
||||||
(definition) => definition.metadata.fieldName === fieldName,
|
(definition) => definition.metadata.fieldName === fieldName,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user