feat: new deployment provider: baotawaf site

This commit is contained in:
Fu Diwei
2025-05-20 21:16:28 +08:00
parent 4ad08d983a
commit 591df58992
22 changed files with 628 additions and 8 deletions

View File

@@ -42,6 +42,7 @@ import DeployNodeConfigFormBaiduCloudCDNConfig from "./DeployNodeConfigFormBaidu
import DeployNodeConfigFormBaishanCDNConfig from "./DeployNodeConfigFormBaishanCDNConfig";
import DeployNodeConfigFormBaotaPanelConsoleConfig from "./DeployNodeConfigFormBaotaPanelConsoleConfig";
import DeployNodeConfigFormBaotaPanelSiteConfig from "./DeployNodeConfigFormBaotaPanelSiteConfig";
import DeployNodeConfigFormBaotaWAFSiteConfig from "./DeployNodeConfigFormBaotaWAFSiteConfig";
import DeployNodeConfigFormBunnyCDNConfig from "./DeployNodeConfigFormBunnyCDNConfig.tsx";
import DeployNodeConfigFormBytePlusCDNConfig from "./DeployNodeConfigFormBytePlusCDNConfig";
import DeployNodeConfigFormCdnflyConfig from "./DeployNodeConfigFormCdnflyConfig";
@@ -237,6 +238,8 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
return <DeployNodeConfigFormBaotaPanelConsoleConfig {...nestedFormProps} />;
case DEPLOYMENT_PROVIDERS.BAOTAPANEL_SITE:
return <DeployNodeConfigFormBaotaPanelSiteConfig {...nestedFormProps} />;
case DEPLOYMENT_PROVIDERS.BAOTAWAF_SITE:
return <DeployNodeConfigFormBaotaWAFSiteConfig {...nestedFormProps} />;
case DEPLOYMENT_PROVIDERS.BUNNY_CDN:
return <DeployNodeConfigFormBunnyCDNConfig {...nestedFormProps} />;
case DEPLOYMENT_PROVIDERS.BYTEPLUS_CDN:

View File

@@ -0,0 +1,78 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input, InputNumber } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
import { validPortNumber } from "@/utils/validators";
type DeployNodeConfigFormBaotaWAFSiteConfigFieldValues = Nullish<{
siteName: string;
sitePort: number;
}>;
export type DeployNodeConfigFormBaotaWAFSiteConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: DeployNodeConfigFormBaotaWAFSiteConfigFieldValues;
onValuesChange?: (values: DeployNodeConfigFormBaotaWAFSiteConfigFieldValues) => void;
};
const initFormModel = (): DeployNodeConfigFormBaotaWAFSiteConfigFieldValues => {
return {
siteName: "",
sitePort: 443,
};
};
const DeployNodeConfigFormBaotaWAFSiteConfig = ({
form: formInst,
formName,
disabled,
initialValues,
onValuesChange,
}: DeployNodeConfigFormBaotaWAFSiteConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
siteName: z.string().nonempty(t("workflow_node.deploy.form.baotawaf_site_name.placeholder")).trim(),
sitePort: z.preprocess(
(v) => Number(v),
z
.number()
.int(t("workflow_node.deploy.form.baotawaf_site_port.placeholder"))
.refine((v) => validPortNumber(v), t("common.errmsg.port_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="siteName"
label={t("workflow_node.deploy.form.baotawaf_site_name.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.baotawaf_site_name.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.deploy.form.baotawaf_site_name.placeholder")} />
</Form.Item>
<Form.Item name="sitePort" label={t("workflow_node.deploy.form.baotawaf_site_port.label")} rules={[formRule]}>
<InputNumber className="w-full" placeholder={t("access.form.ssh_port.placeholder")} min={1} max={65535} />
</Form.Item>
</Form>
);
};
export default DeployNodeConfigFormBaotaWAFSiteConfig;