create.config.ts 3.69 KB
import { MessagePropertiesEnum } from '../../../enum/form';
import { useRuleChainI18n } from '../../../hook/useRuleChainI18n';
import { FormSchema } from '/@/components/Form';

export enum RabbitmqFieldsEnum {
  EXCHANGE_NAME_PATTERN = 'exchangeNamePattern',
  ROUTING_KEY_PATTERN = 'routingKeyPattern',
  MESSAGE_PROPERTIES = 'messageProperties',
  HOST = 'host',
  PORT = 'port',
  VIRTUAL_HOST = 'virtualHost',
  USERNAME = 'username',
  PASSWORD = 'password',
  AUTOMATIC_RECOVERY_ENABLED = 'automaticRecoveryEnabled',
  CONNECTION_TIMEOUT = 'connectionTimeout',
  HANDSHAKE_TIMEOUT = 'handshakeTimeout',
  CLIENT_PROPERTIES = 'clientProperties',
}
const { tLabel, tPlaceholder } = useRuleChainI18n('external', 'rabbitmq');

export const formSchemas: FormSchema[] = [
  {
    field: RabbitmqFieldsEnum.EXCHANGE_NAME_PATTERN,
    label: tLabel(RabbitmqFieldsEnum.EXCHANGE_NAME_PATTERN),
    component: 'Input',
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.EXCHANGE_NAME_PATTERN),
    },
  },
  {
    field: RabbitmqFieldsEnum.ROUTING_KEY_PATTERN,
    label: tLabel(RabbitmqFieldsEnum.ROUTING_KEY_PATTERN),
    component: 'Input',
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.ROUTING_KEY_PATTERN),
    },
  },
  {
    field: RabbitmqFieldsEnum.MESSAGE_PROPERTIES,
    label: tLabel(RabbitmqFieldsEnum.MESSAGE_PROPERTIES),
    component: 'Select',
    componentProps: {
      allowClear: true,
      options: Object.keys(MessagePropertiesEnum).map((value) => ({ label: value, value })),
      placeholder: tPlaceholder(RabbitmqFieldsEnum.ROUTING_KEY_PATTERN, 'choose'),
      getPopupContainer: () => document.body,
    },
  },
  {
    field: RabbitmqFieldsEnum.HOST,
    label: tLabel(RabbitmqFieldsEnum.HOST),
    component: 'Input',
    required: true,
    colProps: { span: 12 },
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.HOST),
    },
  },
  {
    field: RabbitmqFieldsEnum.PORT,
    label: tLabel(RabbitmqFieldsEnum.PORT),
    component: 'InputNumber',
    required: true,
    colProps: { span: 12 },
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.PORT),
    },
  },
  {
    field: RabbitmqFieldsEnum.VIRTUAL_HOST,
    label: tLabel(RabbitmqFieldsEnum.VIRTUAL_HOST),
    component: 'Input',
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.VIRTUAL_HOST),
    },
  },
  {
    field: RabbitmqFieldsEnum.USERNAME,
    label: tLabel(RabbitmqFieldsEnum.USERNAME),
    component: 'Input',
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.USERNAME),
    },
  },
  {
    field: RabbitmqFieldsEnum.PASSWORD,
    label: tLabel(RabbitmqFieldsEnum.PASSWORD),
    component: 'Input',
    componentProps: {
      placeholder: tPlaceholder(RabbitmqFieldsEnum.PASSWORD),
    },
  },
  {
    field: RabbitmqFieldsEnum.AUTOMATIC_RECOVERY_ENABLED,
    component: 'Checkbox',
    label: '',
    renderComponentContent: () => ({
      default: () => tLabel(RabbitmqFieldsEnum.AUTOMATIC_RECOVERY_ENABLED),
    }),
  },
  {
    field: RabbitmqFieldsEnum.CONNECTION_TIMEOUT,
    label: tLabel(RabbitmqFieldsEnum.CONNECTION_TIMEOUT),
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: tPlaceholder(RabbitmqFieldsEnum.CONNECTION_TIMEOUT),
    },
  },
  {
    field: RabbitmqFieldsEnum.HANDSHAKE_TIMEOUT,
    label: tLabel(RabbitmqFieldsEnum.HANDSHAKE_TIMEOUT),
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: tPlaceholder(RabbitmqFieldsEnum.HANDSHAKE_TIMEOUT),
    },
  },
  {
    field: RabbitmqFieldsEnum.CLIENT_PROPERTIES,
    label: tLabel(RabbitmqFieldsEnum.CLIENT_PROPERTIES),
    component: 'Input',
    slot: RabbitmqFieldsEnum.CLIENT_PROPERTIES,
  },
];