+6
-20
@@ -6,9 +6,7 @@ import {
|
||||
type ManualTriggerWorkflowVersion,
|
||||
type Workflow,
|
||||
} from '@/workflow/types/Workflow';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
|
||||
export const useActiveWorkflowVersionsWithManualTrigger = ({
|
||||
objectMetadataItem,
|
||||
@@ -17,10 +15,6 @@ export const useActiveWorkflowVersionsWithManualTrigger = ({
|
||||
objectMetadataItem?: ObjectMetadataItem;
|
||||
skip?: boolean;
|
||||
}) => {
|
||||
const isIteratorEnabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IS_WORKFLOW_ITERATOR_ENABLED,
|
||||
);
|
||||
|
||||
const filters = [
|
||||
{
|
||||
status: {
|
||||
@@ -34,20 +28,12 @@ export const useActiveWorkflowVersionsWithManualTrigger = ({
|
||||
},
|
||||
];
|
||||
|
||||
const objectTypeFilter = isIteratorEnabled
|
||||
? {
|
||||
trigger: {
|
||||
like: `%"objectNameSingular": "${objectMetadataItem?.nameSingular}"%`,
|
||||
},
|
||||
}
|
||||
: {
|
||||
trigger: {
|
||||
like: `%"objectType": "${objectMetadataItem?.nameSingular}"%`,
|
||||
},
|
||||
};
|
||||
|
||||
if (isDefined(objectMetadataItem)) {
|
||||
filters.push(objectTypeFilter);
|
||||
filters.push({
|
||||
trigger: {
|
||||
like: `%"objectNameSingular": "${objectMetadataItem?.nameSingular}"%`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const { records } = useFindManyRecords<
|
||||
@@ -79,7 +65,7 @@ export const useActiveWorkflowVersionsWithManualTrigger = ({
|
||||
(record) =>
|
||||
record.status === 'ACTIVE' &&
|
||||
isDefined(record.trigger) &&
|
||||
isGlobalManualTrigger(record.trigger, isIteratorEnabled),
|
||||
isGlobalManualTrigger(record.trigger),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,47 +1,18 @@
|
||||
import { stepsOutputSchemaFamilyState } from '@/workflow/states/stepsOutputSchemaFamilyState';
|
||||
import {
|
||||
type WorkflowActionType,
|
||||
type WorkflowVersion,
|
||||
} from '@/workflow/types/Workflow';
|
||||
import { type WorkflowVersion } from '@/workflow/types/Workflow';
|
||||
import { getStepOutputSchemaFamilyStateKey } from '@/workflow/utils/getStepOutputSchemaFamilyStateKey';
|
||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||
import { getTriggerDefaultLabel } from '@/workflow/workflow-trigger/utils/getTriggerDefaultLabel';
|
||||
import { getTriggerIcon } from '@/workflow/workflow-trigger/utils/getTriggerIcon';
|
||||
import { isFindRecordsOutputSchema } from '@/workflow/workflow-variables/types/guards/isFindRecordsOutputSchema';
|
||||
import {
|
||||
type OutputSchemaV2,
|
||||
type StepOutputSchemaV2,
|
||||
} from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { TRIGGER_STEP_ID } from 'twenty-shared/workflow';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
|
||||
const getFilteredOutputSchema = ({
|
||||
stepType,
|
||||
outputSchema,
|
||||
isIteratorEnabled,
|
||||
}: {
|
||||
stepType: WorkflowActionType;
|
||||
outputSchema: OutputSchemaV2;
|
||||
isIteratorEnabled: boolean;
|
||||
}) => {
|
||||
if (!isIteratorEnabled && isFindRecordsOutputSchema(stepType, outputSchema)) {
|
||||
const filteredOutputSchema = {
|
||||
...outputSchema,
|
||||
all: undefined,
|
||||
};
|
||||
|
||||
return filteredOutputSchema;
|
||||
}
|
||||
|
||||
return outputSchema;
|
||||
};
|
||||
export const useStepsOutputSchema = () => {
|
||||
const isIteratorEnabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IS_WORKFLOW_ITERATOR_ENABLED,
|
||||
);
|
||||
const populateStepsOutputSchema = useRecoilCallback(
|
||||
({ set }) =>
|
||||
(workflowVersion: WorkflowVersion) => {
|
||||
@@ -51,11 +22,7 @@ export const useStepsOutputSchema = () => {
|
||||
name: step.name,
|
||||
type: step.type,
|
||||
icon: getActionIcon(step.type),
|
||||
outputSchema: getFilteredOutputSchema({
|
||||
stepType: step.type,
|
||||
outputSchema: step.settings?.outputSchema as OutputSchemaV2,
|
||||
isIteratorEnabled,
|
||||
}),
|
||||
outputSchema: step.settings?.outputSchema as OutputSchemaV2,
|
||||
};
|
||||
|
||||
set(
|
||||
@@ -92,7 +59,7 @@ export const useStepsOutputSchema = () => {
|
||||
);
|
||||
}
|
||||
},
|
||||
[isIteratorEnabled],
|
||||
[],
|
||||
);
|
||||
|
||||
const deleteStepsOutputSchema = useRecoilCallback(
|
||||
|
||||
Reference in New Issue
Block a user