Display relation field id reaching max depth (#14101)
Search record action do not fetch relations. We could add it to but the logic used, based on gql filtering will be refactored soon. Issue it that the output schema of the step is displaying relation content as if there were available. This PR: - remove the relation content from search record output schema - replace it by the relation field id so the user can still use it - makes UUID selectable in object record picker field Before https://github.com/user-attachments/assets/1bdb4c24-ef32-4a15-9da9-149f270abb01 After https://github.com/user-attachments/assets/d6e97160-c5a3-4989-a603-0c7ce8128b31
This commit is contained in:
+1
@@ -58,6 +58,7 @@ describe('generateFakeObjectRecord', () => {
|
||||
expect(generateObjectRecordFields).toHaveBeenCalledWith({
|
||||
objectMetadataInfo,
|
||||
depth: 0,
|
||||
maxDepth: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
@@ -5,9 +5,11 @@ import { generateObjectRecordFields } from 'src/modules/workflow/workflow-builde
|
||||
export const generateFakeObjectRecord = ({
|
||||
objectMetadataInfo,
|
||||
depth = 0,
|
||||
maxDepth = 1,
|
||||
}: {
|
||||
objectMetadataInfo: ObjectMetadataInfo;
|
||||
depth?: number;
|
||||
maxDepth?: number;
|
||||
}): RecordOutputSchema => {
|
||||
return {
|
||||
object: {
|
||||
@@ -22,6 +24,7 @@ export const generateFakeObjectRecord = ({
|
||||
fields: generateObjectRecordFields({
|
||||
objectMetadataInfo,
|
||||
depth,
|
||||
maxDepth,
|
||||
}),
|
||||
_outputSchemaType: 'RECORD',
|
||||
};
|
||||
|
||||
+18
-6
@@ -6,15 +6,16 @@ import { type FieldOutputSchema } from 'src/modules/workflow/workflow-builder/wo
|
||||
import { generateFakeObjectRecord } from 'src/modules/workflow/workflow-builder/workflow-schema/utils/generate-fake-object-record';
|
||||
import { generateFakeRecordField } from 'src/modules/workflow/workflow-builder/workflow-schema/utils/generate-fake-record-field';
|
||||
import { shouldGenerateFieldFakeValue } from 'src/modules/workflow/workflow-builder/workflow-schema/utils/should-generate-field-fake-value';
|
||||
|
||||
const MAXIMUM_DEPTH = 1;
|
||||
import { camelToTitleCase } from 'src/utils/camel-to-title-case';
|
||||
|
||||
export const generateObjectRecordFields = ({
|
||||
objectMetadataInfo,
|
||||
depth = 0,
|
||||
maxDepth = 1,
|
||||
}: {
|
||||
objectMetadataInfo: ObjectMetadataInfo;
|
||||
depth?: number;
|
||||
maxDepth?: number;
|
||||
}): Record<string, FieldOutputSchema> => {
|
||||
const objectMetadata = objectMetadataInfo.objectMetadataItemWithFieldsMaps;
|
||||
|
||||
@@ -35,10 +36,11 @@ export const generateObjectRecordFields = ({
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (
|
||||
depth < MAXIMUM_DEPTH &&
|
||||
isDefined(field.relationTargetObjectMetadataId)
|
||||
) {
|
||||
if (!isDefined(field.relationTargetObjectMetadataId)) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (depth < maxDepth) {
|
||||
const relationTargetObjectMetadata =
|
||||
objectMetadataInfo.objectMetadataMaps.byId[
|
||||
field.relationTargetObjectMetadataId
|
||||
@@ -62,6 +64,16 @@ export const generateObjectRecordFields = ({
|
||||
depth: depth + 1,
|
||||
}),
|
||||
};
|
||||
} else if (depth === maxDepth) {
|
||||
const relationIdFieldName = `${field.name}Id`;
|
||||
const relationIdFieldLabel = camelToTitleCase(relationIdFieldName);
|
||||
|
||||
acc[relationIdFieldName] = generateFakeRecordField({
|
||||
type: FieldMetadataType.UUID,
|
||||
label: relationIdFieldLabel,
|
||||
icon: field.icon ?? undefined,
|
||||
fieldMetadataId: field.id,
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
|
||||
+4
-1
@@ -117,6 +117,7 @@ export class WorkflowSchemaWorkspaceService {
|
||||
const recordOutputSchema = await this.computeRecordOutputSchema({
|
||||
objectType,
|
||||
workspaceId,
|
||||
maxDepth: 0,
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -138,9 +139,11 @@ export class WorkflowSchemaWorkspaceService {
|
||||
private async computeRecordOutputSchema({
|
||||
objectType,
|
||||
workspaceId,
|
||||
maxDepth = 1,
|
||||
}: {
|
||||
objectType: string;
|
||||
workspaceId: string;
|
||||
maxDepth?: number;
|
||||
}): Promise<OutputSchema> {
|
||||
const objectMetadataInfo =
|
||||
await this.workflowCommonWorkspaceService.getObjectMetadataItemWithFieldsMaps(
|
||||
@@ -148,7 +151,7 @@ export class WorkflowSchemaWorkspaceService {
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
return generateFakeObjectRecord({ objectMetadataInfo });
|
||||
return generateFakeObjectRecord({ objectMetadataInfo, maxDepth });
|
||||
}
|
||||
|
||||
private computeSendEmailActionOutputSchema(): OutputSchema {
|
||||
|
||||
Reference in New Issue
Block a user