Replace the OSS deployment api
This commit is contained in:
File diff suppressed because one or more lines are too long
2
ui/dist/index.html
vendored
2
ui/dist/index.html
vendored
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Certimate - Your Trusted SSL Automation Partner</title>
|
||||
<script type="module" crossorigin src="/assets/index-DbwFzZm1.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DvxNVikK.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CWUb5Xuf.css">
|
||||
</head>
|
||||
<body class="bg-background">
|
||||
|
||||
@@ -479,7 +479,7 @@ const DeployEdit = ({ type }: DeployEditProps) => {
|
||||
case "dcdn":
|
||||
return <DeployCDN />;
|
||||
case "oss":
|
||||
return <DeployCDN />;
|
||||
return <DeployOSS />;
|
||||
case "webhook":
|
||||
return <DeployWebhook />;
|
||||
default:
|
||||
@@ -659,6 +659,158 @@ const DeployCDN = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const DeployOSS = () => {
|
||||
const { deploy: data, setDeploy, error, setError } = useDeployEditContext();
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
setError({});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const resp = domainSchema.safeParse(data.config?.domain);
|
||||
if (!resp.success) {
|
||||
setError({
|
||||
...error,
|
||||
domain: JSON.parse(resp.error.message)[0].message,
|
||||
});
|
||||
} else {
|
||||
setError({
|
||||
...error,
|
||||
domain: "",
|
||||
});
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
useEffect(() => {
|
||||
const bucketResp = bucketSchema.safeParse(data.config?.domain);
|
||||
if (!bucketResp.success) {
|
||||
setError({
|
||||
...error,
|
||||
bucket: JSON.parse(bucketResp.error.message)[0].message,
|
||||
});
|
||||
} else {
|
||||
setError({
|
||||
...error,
|
||||
bucket: "",
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!data.id) {
|
||||
setDeploy({
|
||||
...data,
|
||||
config: {
|
||||
endpoint: "oss-cn-hangzhou.aliyuncs.com",
|
||||
bucket: "",
|
||||
domain: "",
|
||||
},
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
const domainSchema = z
|
||||
.string()
|
||||
.regex(/^(?:\*\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/, {
|
||||
message: t("domain.not.empty.verify.message"),
|
||||
});
|
||||
|
||||
const bucketSchema = z.string().min(1, {
|
||||
message: t("deployment.access.oss.bucket.not.empty"),
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="flex flex-col space-y-2">
|
||||
<div>
|
||||
<Label>{t("deployment.access.oss.endpoint")}</Label>
|
||||
|
||||
<Input
|
||||
className="w-full mt-1"
|
||||
value={data?.config?.endpoint}
|
||||
onChange={(e) => {
|
||||
const temp = e.target.value;
|
||||
|
||||
const newData = produce(data, (draft) => {
|
||||
if (!draft.config) {
|
||||
draft.config = {};
|
||||
}
|
||||
draft.config.endpoint = temp;
|
||||
});
|
||||
setDeploy(newData);
|
||||
}}
|
||||
/>
|
||||
<div className="text-red-600 text-sm mt-1">{error?.endpoint}</div>
|
||||
|
||||
<Label>{t("deployment.access.oss.bucket")}</Label>
|
||||
<Input
|
||||
placeholder={t("deployment.access.oss.bucket.not.empty")}
|
||||
className="w-full mt-1"
|
||||
value={data?.config?.bucket}
|
||||
onChange={(e) => {
|
||||
const temp = e.target.value;
|
||||
|
||||
const resp = bucketSchema.safeParse(temp);
|
||||
if (!resp.success) {
|
||||
setError({
|
||||
...error,
|
||||
bucket: JSON.parse(resp.error.message)[0].message,
|
||||
});
|
||||
} else {
|
||||
setError({
|
||||
...error,
|
||||
bucket: "",
|
||||
});
|
||||
}
|
||||
|
||||
const newData = produce(data, (draft) => {
|
||||
if (!draft.config) {
|
||||
draft.config = {};
|
||||
}
|
||||
draft.config.bucket = temp;
|
||||
});
|
||||
setDeploy(newData);
|
||||
}}
|
||||
/>
|
||||
<div className="text-red-600 text-sm mt-1">{error?.bucket}</div>
|
||||
|
||||
<Label>{t("deployment.access.cdn.deploy.to.domain")}</Label>
|
||||
<Input
|
||||
placeholder={t("deployment.access.cdn.deploy.to.domain")}
|
||||
className="w-full mt-1"
|
||||
value={data?.config?.domain}
|
||||
onChange={(e) => {
|
||||
const temp = e.target.value;
|
||||
|
||||
const resp = domainSchema.safeParse(temp);
|
||||
if (!resp.success) {
|
||||
setError({
|
||||
...error,
|
||||
domain: JSON.parse(resp.error.message)[0].message,
|
||||
});
|
||||
} else {
|
||||
setError({
|
||||
...error,
|
||||
domain: "",
|
||||
});
|
||||
}
|
||||
|
||||
const newData = produce(data, (draft) => {
|
||||
if (!draft.config) {
|
||||
draft.config = {};
|
||||
}
|
||||
draft.config.domain = temp;
|
||||
});
|
||||
setDeploy(newData);
|
||||
}}
|
||||
/>
|
||||
<div className="text-red-600 text-sm mt-1">{error?.domain}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const DeployWebhook = () => {
|
||||
const { deploy: data, setDeploy } = useDeployEditContext();
|
||||
|
||||
|
||||
@@ -239,5 +239,9 @@
|
||||
"deployment.not.added": "Deployment not added yet",
|
||||
"deployment.access.type": "Access Type",
|
||||
"deployment.access.config": "Access Configuration",
|
||||
"deployment.access.cdn.deploy.to.domain": "Deploy to domain"
|
||||
"deployment.access.cdn.deploy.to.domain": "Deploy to domain",
|
||||
|
||||
"deployment.access.oss.bucket": "Bucket",
|
||||
"deployment.access.oss.bucket.not.empty": "Please enter Bucket",
|
||||
"deployment.access.oss.endpoint": "Endpoint"
|
||||
}
|
||||
|
||||
@@ -239,5 +239,9 @@
|
||||
"deployment.not.added": "暂无部署配置,请添加后开始部署证书吧",
|
||||
"deployment.access.type": "授权类型",
|
||||
"deployment.access.config": "授权配置",
|
||||
"deployment.access.cdn.deploy.to.domain": "部署到域名"
|
||||
"deployment.access.cdn.deploy.to.domain": "部署到域名",
|
||||
|
||||
"deployment.access.oss.bucket": "Bucket",
|
||||
"deployment.access.oss.bucket.not.empty": "请输入 Bucket",
|
||||
"deployment.access.oss.endpoint": "Endpoint"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user