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 { CodeAction, MarkdownVariant } from '@activepieces/shared';
import { t } from 'i18next';
import React from 'react';
import { useFormContext } from 'react-hook-form';
import { DictionaryInput } from '@/components/custom/dictionary-input';
import { ApMarkdown } from '@/components/custom/markdown';
import {
FormField,
FormItem,
FormLabel,
FormMessage,
} from '@/components/ui/form';
import { TextInputWithMentions } from '../../piece-properties/text-input-with-mentions';
import { CodeEditor } from './code-editor';
const markdown = `
To use data from previous steps in your code, include them as pairs of keys and values below.
You can access these inputs in your code using \`inputs.key\`, where \`key\` is the name you assigned below.
`;
const warningMarkdown = `
**const code** is the entry to the code. If it is removed or renamed, your step will fail.
`;
type CodeSettingsProps = {
readonly: boolean;
};
const CodeSettings = React.memo(({ readonly }: CodeSettingsProps) => {
const form = useFormContext<CodeAction>();
return (
<div className="flex flex-col gap-4">
<FormField
control={form.control}
name="settings.input"
render={({ field }) => (
<FormItem>
<div className="pb-4">
<ApMarkdown markdown={markdown} variant={MarkdownVariant.INFO} />
</div>
<div className="flex items-center justify-between mb-2!">
<FormLabel>{t('Inputs')}</FormLabel>
</div>
<DictionaryInput
disabled={readonly}
values={field.value}
onChange={field.onChange}
keyInputClassName="h-[38px]"
renderValueInput={({ value, onChange, disabled }) => (
<TextInputWithMentions
initialValue={value}
disabled={disabled}
onChange={onChange}
ariaLabel={t('Value')}
/>
)}
/>
<FormMessage />
</FormItem>
)}
/>
<div>
<ApMarkdown
markdown={warningMarkdown}
variant={MarkdownVariant.WARNING}
/>
</div>
<FormField
control={form.control}
name="settings.sourceCode"
render={({ field }) => (
<FormItem>
<CodeEditor
sourceCode={field.value}
onChange={field.onChange}
readonly={readonly}
></CodeEditor>
<FormMessage />
</FormItem>
)}
/>
</div>
);
});
CodeSettings.displayName = 'CodeSettings';
export { CodeSettings };