feat: add gcore cdn deployer

This commit is contained in:
Fu Diwei
2025-02-17 22:24:38 +08:00
parent ea02190ad5
commit 7c3f2399c2
43 changed files with 356 additions and 67 deletions

View File

@@ -33,6 +33,7 @@ import DeployNodeConfigFormBaotaPanelSiteConfig from "./DeployNodeConfigFormBaot
import DeployNodeConfigFormBytePlusCDNConfig from "./DeployNodeConfigFormBytePlusCDNConfig";
import DeployNodeConfigFormDogeCloudCDNConfig from "./DeployNodeConfigFormDogeCloudCDNConfig";
import DeployNodeConfigFormEdgioApplicationsConfig from "./DeployNodeConfigFormEdgioApplicationsConfig";
import DeployNodeConfigFormGcoreCDNConfig from "./DeployNodeConfigFormGcoreCDNConfig";
import DeployNodeConfigFormHuaweiCloudCDNConfig from "./DeployNodeConfigFormHuaweiCloudCDNConfig";
import DeployNodeConfigFormHuaweiCloudELBConfig from "./DeployNodeConfigFormHuaweiCloudELBConfig";
import DeployNodeConfigFormHuaweiCloudWAFConfig from "./DeployNodeConfigFormHuaweiCloudWAFConfig";
@@ -167,6 +168,8 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
return <DeployNodeConfigFormDogeCloudCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.EDGIO_APPLICATIONS:
return <DeployNodeConfigFormEdgioApplicationsConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.GCORE_CDN:
return <DeployNodeConfigFormGcoreCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.HUAWEICLOUD_CDN:
return <DeployNodeConfigFormHuaweiCloudCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.HUAWEICLOUD_ELB:
@@ -237,7 +240,7 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
const oldValues = formInst.getFieldsValue();
const newValues: Record<string, unknown> = {};
for (const key in oldValues) {
if (key === "provider" || key === "providerAccessId" || key === "certificate") {
if (key === "provider" || key === "providerAccessId" || key === "certificate" || key === "skipOnLastSucceeded") {
newValues[key] = oldValues[key];
} else {
newValues[key] = undefined;

View File

@@ -0,0 +1,59 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
type DeployNodeConfigFormGcoreCDNConfigFieldValues = Nullish<{
resourceId?: string;
}>;
export type DeployNodeConfigFormGcoreCDNConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: DeployNodeConfigFormGcoreCDNConfigFieldValues;
onValuesChange?: (values: DeployNodeConfigFormGcoreCDNConfigFieldValues) => void;
};
const initFormModel = (): DeployNodeConfigFormGcoreCDNConfigFieldValues => {
return {
resourceId: "",
};
};
const DeployNodeConfigFormGcoreCDNConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: DeployNodeConfigFormGcoreCDNConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
resourceId: z
.string({ message: t("workflow_node.deploy.form.gcore_cdn_certificate_id.placeholder") })
.regex(/^\d+$/, t("workflow_node.deploy.form.gcore_cdn_certificate_id.placeholder")),
});
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="resourceId"
label={t("workflow_node.deploy.form.gcore_cdn_resource_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.gcore_cdn_resource_id.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.deploy.form.gcore_cdn_resource_id.placeholder")} />
</Form.Item>
</Form>
);
};
export default DeployNodeConfigFormGcoreCDNConfig;