AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { FlowAction, FlowTrigger } from '@activepieces/shared';
import { t } from 'i18next';
import { ShieldAlert } from 'lucide-react';
import React from 'react';
import { useFormContext } from 'react-hook-form';
import { ReadMoreDescription } from '@/components/custom/read-more-description';
import {
FormField,
FormItem,
FormLabel,
FormControl,
} from '@/components/ui/form';
import { Switch } from '@/components/ui/switch';
import { cn, GAP_SIZE_FOR_STEP_SETTINGS } from '@/lib/utils';
type ActionErrorHandlingFormProps = {
hideContinueOnFailure?: boolean;
hideRetryOnFailure?: boolean;
disabled: boolean;
};
const ActionErrorHandlingForm = React.memo(
({
hideContinueOnFailure,
hideRetryOnFailure,
disabled,
}: ActionErrorHandlingFormProps) => {
const form = useFormContext<FlowAction | FlowTrigger>();
if (hideContinueOnFailure === true && hideRetryOnFailure === true) {
return null;
}
return (
<div
className={cn(
'flex flex-col border-t border-gray-6 pt-4',
GAP_SIZE_FOR_STEP_SETTINGS,
)}
>
<div className="flex items-center gap-2 text-gray-11">
<ShieldAlert className="size-4" />
<span className="text-sm font-semibold tracking-tight text-gray-11">
{t('Error handling')}
</span>
</div>
{hideContinueOnFailure !== true && (
<FormField
name="settings.errorHandlingOptions.continueOnFailure.value"
control={form.control}
render={({ field }) => (
<FormItem>
<FormLabel
htmlFor="continueOnFailure"
className="flex items-center gap-2.5 h-7.5 max-h-7.5"
>
<FormControl>
<Switch
disabled={disabled}
id="continueOnFailure"
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
<span>{t('Add Error Handler')}</span>
</FormLabel>
<ReadMoreDescription
text={t(
'Adds Success and Failure branches, errors go into Failure.',
)}
/>
</FormItem>
)}
/>
)}
{hideRetryOnFailure !== true && (
<FormField
name="settings.errorHandlingOptions.retryOnFailure.value"
control={form.control}
render={({ field }) => (
<FormItem>
<FormLabel
htmlFor="retryOnFailure"
className="flex items-center gap-2.5 h-7.5 max-h-7.5"
>
<FormControl>
<Switch
disabled={disabled}
id="retryOnFailure"
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
<span>{t('Retry on Failure')}</span>
</FormLabel>
<ReadMoreDescription
text={t('Retries up to 4 times before failing the step.')}
/>
</FormItem>
)}
/>
)}
</div>
);
},
);
ActionErrorHandlingForm.displayName = 'ActionErrorHandlingForm';
export { ActionErrorHandlingForm };