feat: add aws cloudfront deployer

This commit is contained in:
Fu Diwei
2025-01-23 23:21:56 +08:00
parent 1651cda5b4
commit 5ee5460612
42 changed files with 467 additions and 76 deletions

View File

@@ -23,6 +23,7 @@ import DeployNodeConfigFormAliyunLiveConfig from "./DeployNodeConfigFormAliyunLi
import DeployNodeConfigFormAliyunNLBConfig from "./DeployNodeConfigFormAliyunNLBConfig";
import DeployNodeConfigFormAliyunOSSConfig from "./DeployNodeConfigFormAliyunOSSConfig";
import DeployNodeConfigFormAliyunWAFConfig from "./DeployNodeConfigFormAliyunWAFConfig";
import DeployNodeConfigFormAWSCloudFrontConfig from "./DeployNodeConfigFormAWSCloudFrontConfig";
import DeployNodeConfigFormBaiduCloudCDNConfig from "./DeployNodeConfigFormBaiduCloudCDNConfig";
import DeployNodeConfigFormBytePlusCDNConfig from "./DeployNodeConfigFormBytePlusCDNConfig";
import DeployNodeConfigFormDogeCloudCDNConfig from "./DeployNodeConfigFormDogeCloudCDNConfig";
@@ -136,6 +137,8 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
return <DeployNodeConfigFormAliyunOSSConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.ALIYUN_WAF:
return <DeployNodeConfigFormAliyunWAFConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.AWS_CLOUDFRONT:
return <DeployNodeConfigFormAWSCloudFrontConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.BAIDUCLOUD_CDN:
return <DeployNodeConfigFormBaiduCloudCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.BYTEPLUS_CDN:

View File

@@ -0,0 +1,79 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
type DeployNodeConfigFormAWSCloudFrontConfigFieldValues = Nullish<{
region: string;
distributionId: string;
}>;
export type DeployNodeConfigFormAWSCloudFrontConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: DeployNodeConfigFormAWSCloudFrontConfigFieldValues;
onValuesChange?: (values: DeployNodeConfigFormAWSCloudFrontConfigFieldValues) => void;
};
const initFormModel = (): DeployNodeConfigFormAWSCloudFrontConfigFieldValues => {
return {};
};
const DeployNodeConfigFormAWSCloudFrontConfig = ({
form: formInst,
formName,
disabled,
initialValues,
onValuesChange,
}: DeployNodeConfigFormAWSCloudFrontConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
region: z
.string({ message: t("workflow_node.deploy.form.aws_cloudfront_region.placeholder") })
.nonempty(t("workflow_node.deploy.form.aws_cloudfront_region.placeholder"))
.trim(),
distributionId: z
.string({ message: t("workflow_node.deploy.form.aws_cloudfront_distribution_id.placeholder") })
.nonempty(t("workflow_node.deploy.form.aws_cloudfront_distribution_id.placeholder"))
.max(64, t("common.errmsg.string_max", { max: 64 }))
.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="region"
label={t("workflow_node.deploy.form.aws_cloudfront_region.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.aws_cloudfront_region.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.deploy.form.aws_cloudfront_region.placeholder")} />
</Form.Item>
<Form.Item
name="distributionId"
label={t("workflow_node.deploy.form.aws_cloudfront_distribution_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.aws_cloudfront_distribution_id.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.deploy.form.aws_cloudfront_distribution_id.placeholder")} />
</Form.Item>
</Form>
);
};
export default DeployNodeConfigFormAWSCloudFrontConfig;

View File

@@ -35,8 +35,8 @@ const DeployNodeConfigFormAliyunWAFConfig = ({
.nonempty(t("workflow_node.deploy.form.aliyun_waf_region.placeholder"))
.trim(),
instanceId: z
.string({ message: t("workflow_node.deploy.form.aliyun_instance_id.placeholder") })
.nonempty(t("workflow_node.deploy.form.aliyun_instance_id.placeholder"))
.string({ message: t("workflow_node.deploy.form.aliyun_waf_instance_id.placeholder") })
.nonempty(t("workflow_node.deploy.form.aliyun_waf_instance_id.placeholder"))
.max(64, t("common.errmsg.string_max", { max: 64 }))
.trim(),
});