create.config.ts 1.17 KB
import { useRuleChainI18n } from '../../../hook/useRuleChainI18n';
import {
  JavascriptEditorWithTestModal,
  ScriptEditorValueType,
} from '../../../src/components/JavaScriptFilterModal';
import { DefaultNodeConfig } from '../../../types/node';
import { FormSchema, useComponentRegister } from '/@/components/Form';
const { tLabel, t } = useRuleChainI18n('action', 'log');

useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal);

export interface FormFieldsValue {
  [LogFieldsEnum.JS_SCRIPT]: ScriptEditorValueType;
}

export interface NodeConfigValue extends DefaultNodeConfig, ScriptEditorValueType {}

export enum LogFieldsEnum {
  JS_SCRIPT = 'jsScript',
}

export const formSchemas: FormSchema[] = [
  {
    field: LogFieldsEnum.JS_SCRIPT,
    component: 'JavascriptEditorWithTestModal',
    label: tLabel(LogFieldsEnum.JS_SCRIPT),
    valueField: 'value',
    changeEvent: 'update:value',
    componentProps: {
      javaScriptEditorProps: {
        functionName: 'ToString',
        scriptType: 'string',
        paramsName: ['msg', 'metadata', 'msgType'],
      },
      buttonName: t('rule.chain.action.log.fields.jsScriptButtonName'),
    },
  },
];