From e4fd1e78f5371580edf9beb83f1e50c81f486a53 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Thu, 20 Mar 2025 21:53:02 +0800 Subject: [PATCH] feat: add upyun file deployer --- internal/deployer/providers.go | 4 +- internal/domain/provider.go | 1 + .../DeployNodeConfigFormUpyunFileConfig.tsx | 65 +++++++++++++++++++ ui/src/domain/provider.ts | 2 + ui/src/i18n/locales/en/nls.provider.json | 1 + .../i18n/locales/en/nls.workflow.nodes.json | 3 + ui/src/i18n/locales/zh/nls.provider.json | 1 + .../i18n/locales/zh/nls.workflow.nodes.json | 3 + 8 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 ui/src/components/workflow/node/DeployNodeConfigFormUpyunFileConfig.tsx diff --git a/internal/deployer/providers.go b/internal/deployer/providers.go index 7d62ac41..2508fe5c 100644 --- a/internal/deployer/providers.go +++ b/internal/deployer/providers.go @@ -777,7 +777,7 @@ func createDeployer(options *deployerOptions) (deployer.Deployer, error) { } } - case domain.DeployProviderTypeUpyunCDN: + case domain.DeployProviderTypeUpyunCDN, domain.DeployProviderTypeUpyunFile: { access := domain.AccessConfigForUpyun{} if err := maputil.Populate(options.ProviderAccessConfig, &access); err != nil { @@ -785,7 +785,7 @@ func createDeployer(options *deployerOptions) (deployer.Deployer, error) { } switch options.Provider { - case domain.DeployProviderTypeUpyunCDN: + case domain.DeployProviderTypeUpyunCDN, domain.DeployProviderTypeUpyunFile: deployer, err := pUpyunCDN.NewDeployer(&pUpyunCDN.DeployerConfig{ Username: access.Username, Password: access.Password, diff --git a/internal/domain/provider.go b/internal/domain/provider.go index cbc034fa..472d8aeb 100644 --- a/internal/domain/provider.go +++ b/internal/domain/provider.go @@ -161,6 +161,7 @@ const ( DeployProviderTypeUCloudUCDN = DeployProviderType("ucloud-ucdn") DeployProviderTypeUCloudUS3 = DeployProviderType("ucloud-us3") DeployProviderTypeUpyunCDN = DeployProviderType("upyun-cdn") + DeployProviderTypeUpyunFile = DeployProviderType("upyun-file") DeployProviderTypeVolcEngineCDN = DeployProviderType("volcengine-cdn") DeployProviderTypeVolcEngineCLB = DeployProviderType("volcengine-clb") DeployProviderTypeVolcEngineDCDN = DeployProviderType("volcengine-dcdn") diff --git a/ui/src/components/workflow/node/DeployNodeConfigFormUpyunFileConfig.tsx b/ui/src/components/workflow/node/DeployNodeConfigFormUpyunFileConfig.tsx new file mode 100644 index 00000000..c5b3902d --- /dev/null +++ b/ui/src/components/workflow/node/DeployNodeConfigFormUpyunFileConfig.tsx @@ -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 DeployNodeConfigFormUpyunFileConfigFieldValues = Nullish<{ + domain: string; +}>; + +export type DeployNodeConfigFormUpyunFileConfigProps = { + form: FormInstance; + formName: string; + disabled?: boolean; + initialValues?: DeployNodeConfigFormUpyunFileConfigFieldValues; + onValuesChange?: (values: DeployNodeConfigFormUpyunFileConfigFieldValues) => void; +}; + +const initFormModel = (): DeployNodeConfigFormUpyunFileConfigFieldValues => { + return {}; +}; + +const DeployNodeConfigFormUpyunFileConfig = ({ + form: formInst, + formName, + disabled, + initialValues, + onValuesChange, +}: DeployNodeConfigFormUpyunFileConfigProps) => { + const { t } = useTranslation(); + + const formSchema = z.object({ + domain: z + .string({ message: t("workflow_node.deploy.form.upyun_file_domain.placeholder") }) + .refine((v) => validDomainName(v), t("common.errmsg.domain_invalid")), + }); + const formRule = createSchemaFieldRule(formSchema); + + const handleFormChange = (_: unknown, values: z.infer) => { + onValuesChange?.(values); + }; + + return ( +
+ } + > + + +
+ ); +}; + +export default DeployNodeConfigFormUpyunFileConfig; diff --git a/ui/src/domain/provider.ts b/ui/src/domain/provider.ts index 998ec718..f2a8a2b2 100644 --- a/ui/src/domain/provider.ts +++ b/ui/src/domain/provider.ts @@ -266,6 +266,7 @@ export const DEPLOY_PROVIDERS = Object.freeze({ UCLOUD_UCDN: `${ACCESS_PROVIDERS.UCLOUD}-ucdn`, UCLOUD_US3: `${ACCESS_PROVIDERS.UCLOUD}-us3`, UPYUN_CDN: `${ACCESS_PROVIDERS.UPYUN}-cdn`, + UPYUN_FILE: `${ACCESS_PROVIDERS.UPYUN}-file`, VOLCENGINE_CDN: `${ACCESS_PROVIDERS.VOLCENGINE}-cdn`, VOLCENGINE_CLB: `${ACCESS_PROVIDERS.VOLCENGINE}-clb`, VOLCENGINE_DCDN: `${ACCESS_PROVIDERS.VOLCENGINE}-dcdn`, @@ -347,6 +348,7 @@ export const deployProvidersMap: Maphttps://console.upyun.com/services/cdn/", + "workflow_node.deploy.form.upyun_file_domain.label": "UPYUN bucket domain", + "workflow_node.deploy.form.upyun_file_domain.placeholder": "Please enter UPYUN bucket domain name", + "workflow_node.deploy.form.upyun_file_domain.tooltip": "For more information, see https://console.upyun.com/services/file/", "workflow_node.deploy.form.volcengine_cdn_domain.label": "VolcEngine CDN domain", "workflow_node.deploy.form.volcengine_cdn_domain.placeholder": "Please enter VolcEngine CDN domain name", "workflow_node.deploy.form.volcengine_cdn_domain.tooltip": "For more information, see https://console.volcengine.com/cdn/homepage", diff --git a/ui/src/i18n/locales/zh/nls.provider.json b/ui/src/i18n/locales/zh/nls.provider.json index 2e830cf3..03c6aaee 100644 --- a/ui/src/i18n/locales/zh/nls.provider.json +++ b/ui/src/i18n/locales/zh/nls.provider.json @@ -95,6 +95,7 @@ "provider.ucloud.us3": "优刻得 - 对象存储 US3", "provider.upyun": "又拍云", "provider.upyun.cdn": "又拍云 - 云分发 CDN", + "provider.upyun.file": "又拍云 - 云存储", "provider.volcengine": "火山引擎", "provider.volcengine.cdn": "火山引擎 - 内容分发网络 CDN", "provider.volcengine.clb": "火山引擎 - 负载均衡 CLB", diff --git a/ui/src/i18n/locales/zh/nls.workflow.nodes.json b/ui/src/i18n/locales/zh/nls.workflow.nodes.json index 63d881f8..5880613d 100644 --- a/ui/src/i18n/locales/zh/nls.workflow.nodes.json +++ b/ui/src/i18n/locales/zh/nls.workflow.nodes.json @@ -511,6 +511,9 @@ "workflow_node.deploy.form.upyun_cdn_domain.label": "又拍云 CDN 加速域名", "workflow_node.deploy.form.upyun_cdn_domain.placeholder": "请输入又拍云 CDN 加速域名(支持泛域名)", "workflow_node.deploy.form.upyun_cdn_domain.tooltip": "这是什么?请参阅 https://console.upyun.com/services/cdn/", + "workflow_node.deploy.form.upyun_file_domain.label": "又拍云云存储加速域名", + "workflow_node.deploy.form.upyun_file_domain.placeholder": "请输入又拍云云存储加速域名", + "workflow_node.deploy.form.upyun_file_domain.tooltip": "这是什么?请参阅 https://console.upyun.com/services/file/", "workflow_node.deploy.form.volcengine_cdn_domain.label": "火山引擎 CDN 加速域名", "workflow_node.deploy.form.volcengine_cdn_domain.placeholder": "请输入火山引擎 CDN 加速域名(支持泛域名)", "workflow_node.deploy.form.volcengine_cdn_domain.tooltip": "这是什么?请参阅 https://console.volcengine.com/cdn/homepage",