fix tencent clb deploy failed

- 新增region参数
- 新增配置说明
This commit is contained in:
Leo Chen
2024-10-23 23:56:22 +08:00
parent 7544286b0f
commit 6875151717
4 changed files with 62 additions and 4 deletions

View File

@@ -61,6 +61,21 @@ const DeployToTencentCLB = () => {
}
}, [data]);
useEffect(() => {
const regionResp = regionSchema.safeParse(data.config?.region);
if (!regionResp.success) {
setError({
...error,
region: JSON.parse(regionResp.error.message)[0].message,
});
} else {
setError({
...error,
region: "",
});
}
}, []);
useEffect(() => {
if (!data.id) {
@@ -70,11 +85,16 @@ const DeployToTencentCLB = () => {
lsnId: "",
clbId: "",
domain: "",
region: "",
},
});
}
}, []);
const regionSchema = z.string().regex(/^ap-[a-z]+$/, {
message: t("domain.deployment.form.clb_region.placeholder"),
});
const domainSchema = z.string().regex(/^$|^(?:\*\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/, {
message: t("common.errmsg.domain_invalid"),
});
@@ -89,6 +109,40 @@ const DeployToTencentCLB = () => {
return (
<div className="flex flex-col space-y-8">
<div>
<Label>{t("domain.deployment.form.clb_region.label")}</Label>
<Input
placeholder={t("domain.deployment.form.clb_region.placeholder")}
className="w-full mt-1"
value={data?.config?.region}
onChange={(e) => {
const temp = e.target.value;
const resp = regionSchema.safeParse(temp);
if (!resp.success) {
setError({
...error,
region: JSON.parse(resp.error.message)[0].message,
});
} else {
setError({
...error,
region: "",
});
}
const newData = produce(data, (draft) => {
if (!draft.config) {
draft.config = {};
}
draft.config.region = temp;
});
setDeploy(newData);
}}
/>
<div className="text-red-600 text-sm mt-1">{error?.region}</div>
</div>
<div>
<Label>{t("domain.deployment.form.clb_id.label")}</Label>
<Input