feat: add jdcloud dns-01 applicant

This commit is contained in:
Fu Diwei
2025-02-19 23:57:22 +08:00
parent 469c24751e
commit 72896e052c
24 changed files with 502 additions and 15 deletions

View File

@@ -35,6 +35,7 @@ import { validDomainName, validIPv4Address, validIPv6Address } from "@/utils/val
import ApplyNodeConfigFormAWSRoute53Config from "./ApplyNodeConfigFormAWSRoute53Config";
import ApplyNodeConfigFormHuaweiCloudDNSConfig from "./ApplyNodeConfigFormHuaweiCloudDNSConfig";
import ApplyNodeConfigFormJDCloudDNSConfig from "./ApplyNodeConfigFormJDCloudDNSConfig";
type ApplyNodeConfigFormFieldValues = Partial<WorkflowNodeConfigForApply>;
@@ -145,6 +146,9 @@ const ApplyNodeConfigForm = forwardRef<ApplyNodeConfigFormInstance, ApplyNodeCon
case APPLY_DNS_PROVIDERS.HUAWEICLOUD:
case APPLY_DNS_PROVIDERS.HUAWEICLOUD_DNS:
return <ApplyNodeConfigFormHuaweiCloudDNSConfig {...nestedFormProps} />;
case APPLY_DNS_PROVIDERS.JDCLOUD:
case APPLY_DNS_PROVIDERS.JDCLOUD_DNS:
return <ApplyNodeConfigFormJDCloudDNSConfig {...nestedFormProps} />;
}
}, [disabled, initialValues?.providerConfig, fieldProvider, nestedFormInst, nestedFormName]);

View File

@@ -0,0 +1,61 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
type ApplyNodeConfigFormJDCloudDNSConfigFieldValues = Nullish<{
regionId: string;
}>;
export type ApplyNodeConfigFormJDCloudDNSConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: ApplyNodeConfigFormJDCloudDNSConfigFieldValues;
onValuesChange?: (values: ApplyNodeConfigFormJDCloudDNSConfigFieldValues) => void;
};
const initFormModel = (): ApplyNodeConfigFormJDCloudDNSConfigFieldValues => {
return {
regionId: "cn-north-1",
};
};
const ApplyNodeConfigFormJDCloudDNSConfig = ({
form: formInst,
formName,
disabled,
initialValues,
onValuesChange,
}: ApplyNodeConfigFormJDCloudDNSConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
regionId: z
.string({ message: t("workflow_node.apply.form.jdcloud_dns_region_id.placeholder") })
.nonempty(t("workflow_node.apply.form.jdcloud_dns_region_id.placeholder"))
.trim(),
});
const formRule = createSchemaFieldRule(formSchema);
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
onValuesChange?.(values);
};
return (
<Form
form={formInst}
disabled={disabled}
initialValues={initialValues ?? initFormModel()}
layout="vertical"
name={formName}
onValuesChange={handleFormChange}
>
<Form.Item name="regionId" label={t("workflow_node.apply.form.jdcloud_dns_region_id_id.label")} rules={[formRule]}>
<Input placeholder={t("workflow_node.apply.form.jdcloud_dns_region_id.placeholder")} />
</Form.Item>
</Form>
);
};
export default ApplyNodeConfigFormJDCloudDNSConfig;