feat: add jdcloud cdn deployer

This commit is contained in:
Fu Diwei
2025-02-20 00:51:34 +08:00
parent 0e1f720419
commit 5139198691
15 changed files with 276 additions and 73 deletions

View File

@@ -51,7 +51,12 @@ const ApplyNodeConfigFormJDCloudDNSConfig = ({
name={formName}
onValuesChange={handleFormChange}
>
<Form.Item name="regionId" label={t("workflow_node.apply.form.jdcloud_dns_region_id_id.label")} rules={[formRule]}>
<Form.Item
name="regionId"
label={t("workflow_node.apply.form.jdcloud_dns_region_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.apply.form.jdcloud_dns_region_id.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.apply.form.jdcloud_dns_region_id.placeholder")} />
</Form.Item>
</Form>

View File

@@ -38,6 +38,7 @@ import DeployNodeConfigFormGcoreCDNConfig from "./DeployNodeConfigFormGcoreCDNCo
import DeployNodeConfigFormHuaweiCloudCDNConfig from "./DeployNodeConfigFormHuaweiCloudCDNConfig";
import DeployNodeConfigFormHuaweiCloudELBConfig from "./DeployNodeConfigFormHuaweiCloudELBConfig";
import DeployNodeConfigFormHuaweiCloudWAFConfig from "./DeployNodeConfigFormHuaweiCloudWAFConfig";
import DeployNodeConfigFormJDCloudCDNConfig from "./DeployNodeConfigFormJDCloudCDNConfig";
import DeployNodeConfigFormKubernetesSecretConfig from "./DeployNodeConfigFormKubernetesSecretConfig";
import DeployNodeConfigFormLocalConfig from "./DeployNodeConfigFormLocalConfig";
import DeployNodeConfigFormQiniuCDNConfig from "./DeployNodeConfigFormQiniuCDNConfig";
@@ -178,6 +179,8 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
return <DeployNodeConfigFormHuaweiCloudELBConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.HUAWEICLOUD_WAF:
return <DeployNodeConfigFormHuaweiCloudWAFConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.JDCLOUD_CDN:
return <DeployNodeConfigFormJDCloudCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.KUBERNETES_SECRET:
return <DeployNodeConfigFormKubernetesSecretConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.LOCAL:

View File

@@ -0,0 +1,65 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
import { validDomainName } from "@/utils/validators";
type DeployNodeConfigFormJDCloudCDNConfigFieldValues = Nullish<{
domain: string;
}>;
export type DeployNodeConfigFormJDCloudCDNConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: DeployNodeConfigFormJDCloudCDNConfigFieldValues;
onValuesChange?: (values: DeployNodeConfigFormJDCloudCDNConfigFieldValues) => void;
};
const initFormModel = (): DeployNodeConfigFormJDCloudCDNConfigFieldValues => {
return {};
};
const DeployNodeConfigFormJDCloudCDNConfig = ({
form: formInst,
formName,
disabled,
initialValues,
onValuesChange,
}: DeployNodeConfigFormJDCloudCDNConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
domain: z
.string({ message: t("workflow_node.deploy.form.jdcloud_cdn_domain.placeholder") })
.refine((v) => validDomainName(v, { allowWildcard: true }), t("common.errmsg.domain_invalid")),
});
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="domain"
label={t("workflow_node.deploy.form.jdcloud_cdn_domain.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.jdcloud_cdn_domain.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.deploy.form.jdcloud_cdn_domain.placeholder")} />
</Form.Item>
</Form>
);
};
export default DeployNodeConfigFormJDCloudCDNConfig;