feat: add ucloud ucdn deployer

This commit is contained in:
Fu Diwei
2025-01-14 21:31:10 +08:00
parent e430109228
commit e87ac72281
23 changed files with 559 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import { memo, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Avatar, Space, Typography } from "antd";
import { Avatar, Flex, Typography } from "antd";
import { produce } from "immer";
import { deployProvidersMap } from "@/domain/provider";
@@ -45,10 +45,10 @@ const DeployNode = ({ node, disabled }: DeployNodeProps) => {
const config = (node.config as WorkflowNodeConfigForDeploy) ?? {};
const provider = deployProvidersMap.get(config.provider);
return (
<Space className="max-w-full">
<Flex className="size-full overflow-hidden" align="center" gap={8}>
<Avatar src={provider?.icon} size="small" />
<Typography.Text className="truncate">{t(provider?.name ?? "")}</Typography.Text>
</Space>
<Typography.Text className="flex-1 truncate">{t(provider?.name ?? "")}</Typography.Text>
</Flex>
);
}, [node]);

View File

@@ -37,6 +37,7 @@ import DeployNodeConfigFormTencentCloudCOSConfig from "./DeployNodeConfigFormTen
import DeployNodeConfigFormTencentCloudCSSConfig from "./DeployNodeConfigFormTencentCloudCSSConfig.tsx";
import DeployNodeConfigFormTencentCloudECDNConfig from "./DeployNodeConfigFormTencentCloudECDNConfig.tsx";
import DeployNodeConfigFormTencentCloudEOConfig from "./DeployNodeConfigFormTencentCloudEOConfig.tsx";
import DeployNodeConfigFormUCloudUCDNConfig from "./DeployNodeConfigFormUCloudUCDNConfig.tsx";
import DeployNodeConfigFormVolcEngineCDNConfig from "./DeployNodeConfigFormVolcEngineCDNConfig.tsx";
import DeployNodeConfigFormVolcEngineCLBConfig from "./DeployNodeConfigFormVolcEngineCLBConfig.tsx";
import DeployNodeConfigFormVolcEngineDCDNConfig from "./DeployNodeConfigFormVolcEngineDCDNConfig.tsx";
@@ -156,6 +157,8 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
return <DeployNodeConfigFormTencentCloudECDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.TENCENTCLOUD_EO:
return <DeployNodeConfigFormTencentCloudEOConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.UCLOUD_UCDN:
return <DeployNodeConfigFormUCloudUCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.VOLCENGINE_CDN:
return <DeployNodeConfigFormVolcEngineCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.VOLCENGINE_CLB:

View File

@@ -0,0 +1,63 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
type DeployNodeConfigFormUCloudUCDNConfigFieldValues = Nullish<{
domainId: string;
}>;
export type DeployNodeConfigFormUCloudUCDNConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: DeployNodeConfigFormUCloudUCDNConfigFieldValues;
onValuesChange?: (values: DeployNodeConfigFormUCloudUCDNConfigFieldValues) => void;
};
const initFormModel = (): DeployNodeConfigFormUCloudUCDNConfigFieldValues => {
return {};
};
const DeployNodeConfigFormUCloudUCDNConfig = ({
form: formInst,
formName,
disabled,
initialValues,
onValuesChange,
}: DeployNodeConfigFormUCloudUCDNConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
domainId: z
.string({ message: t("workflow_node.deploy.form.ucloud_ucdn_domain_id.placeholder") })
.nonempty(t("workflow_node.deploy.form.ucloud_ucdn_domain_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="domainId"
label={t("workflow_node.deploy.form.ucloud_ucdn_domain_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.ucloud_ucdn_domain_id.tooltip") }}></span>}
>
<Input placeholder={t("workflow_node.deploy.form.ucloud_ucdn_domain_id.placeholder")} />
</Form.Item>
</Form>
);
};
export default DeployNodeConfigFormUCloudUCDNConfig;

View File

@@ -1,6 +1,6 @@
import { memo, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Typography } from "antd";
import { Flex, Typography } from "antd";
import { produce } from "immer";
import { notifyChannelsMap } from "@/domain/settings";
@@ -40,12 +40,12 @@ const NotifyNode = ({ node, disabled }: NotifyNodeProps) => {
const config = (node.config as WorkflowNodeConfigForNotify) ?? {};
const channel = notifyChannelsMap.get(config.channel as string);
return (
<div className="flex items-center justify-between space-x-2">
<Typography.Text className="truncate">{t(channel?.name ?? " ")}</Typography.Text>
<Flex className="size-full overflow-hidden" align="center" gap={8}>
<Typography.Text className="flex-1 truncate">{t(channel?.name ?? " ")}</Typography.Text>
<Typography.Text className="truncate" type="secondary">
{config.subject ?? ""}
</Typography.Text>
</div>
</Flex>
);
}, [node]);