import { useTranslation } from "react-i18next"; import { Alert, Form, type FormInstance, Input } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import MultipleSplitValueInput from "@/components/MultipleSplitValueInput"; type DeployNodeConfigFormAliyunCASDeployConfigFieldValues = Nullish<{ region: string; resourceIds: string; contactIds?: string; }>; export type DeployNodeConfigFormAliyunCASDeployConfigProps = { form: FormInstance; formName: string; disabled?: boolean; initialValues?: DeployNodeConfigFormAliyunCASDeployConfigFieldValues; onValuesChange?: (values: DeployNodeConfigFormAliyunCASDeployConfigFieldValues) => void; }; const MULTIPLE_INPUT_SEPARATOR = ";"; const initFormModel = (): DeployNodeConfigFormAliyunCASDeployConfigFieldValues => { return {}; }; const DeployNodeConfigFormAliyunCASDeployConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange, }: DeployNodeConfigFormAliyunCASDeployConfigProps) => { const { t } = useTranslation(); const formSchema = z.object({ region: z .string({ message: t("workflow_node.deploy.form.aliyun_cas_deploy_region.placeholder") }) .nonempty(t("workflow_node.deploy.form.aliyun_cas_deploy_region.placeholder")) .trim(), resourceIds: z.string({ message: t("workflow_node.deploy.form.aliyun_cas_deploy_resource_ids.placeholder") }).refine((v) => { if (!v) return false; return String(v) .split(MULTIPLE_INPUT_SEPARATOR) .every((e) => /^[1-9]\d*$/.test(e)); }, t("workflow_node.deploy.form.aliyun_cas_deploy_resource_ids.errmsg.invalid")), contactIds: z .string({ message: t("workflow_node.deploy.form.aliyun_cas_deploy_contact_ids.placeholder") }) .nullish() .refine((v) => { if (!v) return true; return String(v) .split(MULTIPLE_INPUT_SEPARATOR) .every((e) => /^[1-9]\d*$/.test(e)); }, t("workflow_node.deploy.form.aliyun_cas_deploy_contact_ids.errmsg.invalid")), }); const formRule = createSchemaFieldRule(formSchema); const handleFormChange = (_: unknown, values: z.infer) => { onValuesChange?.(values); }; return (
} > } > } > } />
); }; export default DeployNodeConfigFormAliyunCASDeployConfig;