feat: add 1panel deployer
This commit is contained in:
@@ -9,6 +9,7 @@ import { type AccessModel } from "@/domain/access";
|
||||
import { ACCESS_PROVIDERS } from "@/domain/provider";
|
||||
import { useAntdForm, useAntdFormName } from "@/hooks";
|
||||
|
||||
import AccessForm1PanelConfig from "./AccessForm1PanelConfig";
|
||||
import AccessFormACMEHttpReqConfig from "./AccessFormACMEHttpReqConfig";
|
||||
import AccessFormAliyunConfig from "./AccessFormAliyunConfig";
|
||||
import AccessFormAWSConfig from "./AccessFormAWSConfig";
|
||||
@@ -99,6 +100,8 @@ const AccessForm = forwardRef<AccessFormInstance, AccessFormProps>(({ className,
|
||||
NOTICE: If you add new child component, please keep ASCII order.
|
||||
*/
|
||||
switch (fieldProvider) {
|
||||
case ACCESS_PROVIDERS["1PANEL"]:
|
||||
return <AccessForm1PanelConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.ACMEHTTPREQ:
|
||||
return <AccessFormACMEHttpReqConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.ALIYUN:
|
||||
|
||||
72
ui/src/components/access/AccessForm1PanelConfig.tsx
Normal file
72
ui/src/components/access/AccessForm1PanelConfig.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigFor1Panel } from "@/domain/access";
|
||||
|
||||
type AccessForm1PanelConfigFieldValues = Nullish<AccessConfigFor1Panel>;
|
||||
|
||||
export type AccessForm1PanelConfigProps = {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessForm1PanelConfigFieldValues;
|
||||
onValuesChange?: (values: AccessForm1PanelConfigFieldValues) => void;
|
||||
};
|
||||
|
||||
const initFormModel = (): AccessForm1PanelConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:20410/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessForm1PanelConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessForm1PanelConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.1panel_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.trim(),
|
||||
});
|
||||
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="apiUrl"
|
||||
label={t("access.form.1panel_api_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.1panel_api_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.1panel_api_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.1panel_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.1panel_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.1panel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessForm1PanelConfig;
|
||||
@@ -17,7 +17,7 @@ export type AccessFormBaotaPanelConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormBaotaPanelConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-ipaddr>:8888/",
|
||||
apiUrl: "http://<your-host-addr>:8888/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormCdnflyConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormCdnflyConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-ipaddr>:88/",
|
||||
apiUrl: "http://<your-host-addr>:88/",
|
||||
apiKey: "",
|
||||
apiSecret: "",
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormPowerDNSConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormPowerDNSConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-ipaddr>:8082/",
|
||||
apiUrl: "http://<your-host-addr>:8082/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormSafeLineConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormSafeLineConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-ipaddr>:9443/",
|
||||
apiUrl: "http://<your-host-addr>:9443/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
@@ -15,6 +15,8 @@ import { type WorkflowNode, type WorkflowNodeConfigForDeploy } from "@/domain/wo
|
||||
import { useAntdForm, useAntdFormName, useZustandShallowSelector } from "@/hooks";
|
||||
import { useWorkflowStore } from "@/stores/workflow";
|
||||
|
||||
import DeployNodeConfigForm1PanelConsoleConfig from "./DeployNodeConfigForm1PanelConsoleConfig";
|
||||
import DeployNodeConfigForm1PanelSiteConfig from "./DeployNodeConfigForm1PanelSiteConfig";
|
||||
import DeployNodeConfigFormAliyunALBConfig from "./DeployNodeConfigFormAliyunALBConfig";
|
||||
import DeployNodeConfigFormAliyunCASDeployConfig from "./DeployNodeConfigFormAliyunCASDeployConfig";
|
||||
import DeployNodeConfigFormAliyunCDNConfig from "./DeployNodeConfigFormAliyunCDNConfig";
|
||||
@@ -138,6 +140,10 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
|
||||
NOTICE: If you add new child component, please keep ASCII order.
|
||||
*/
|
||||
switch (fieldProvider) {
|
||||
case DEPLOY_PROVIDERS["1PANEL_CONSOLE"]:
|
||||
return <DeployNodeConfigForm1PanelConsoleConfig {...nestedFormProps} />;
|
||||
case DEPLOY_PROVIDERS["1PANEL_SITE"]:
|
||||
return <DeployNodeConfigForm1PanelSiteConfig {...nestedFormProps} />;
|
||||
case DEPLOY_PROVIDERS.ALIYUN_ALB:
|
||||
return <DeployNodeConfigFormAliyunALBConfig {...nestedFormProps} />;
|
||||
case DEPLOY_PROVIDERS.ALIYUN_CAS_DEPLOY:
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
type DeployNodeConfigForm1PanelConsoleConfigFieldValues = Nullish<{
|
||||
autoRestart?: boolean;
|
||||
}>;
|
||||
|
||||
export type DeployNodeConfigForm1PanelConsoleConfigProps = {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: DeployNodeConfigForm1PanelConsoleConfigFieldValues;
|
||||
onValuesChange?: (values: DeployNodeConfigForm1PanelConsoleConfigFieldValues) => void;
|
||||
};
|
||||
|
||||
const initFormModel = (): DeployNodeConfigForm1PanelConsoleConfigFieldValues => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const DeployNodeConfigForm1PanelConsoleConfig = ({
|
||||
form: formInst,
|
||||
formName,
|
||||
disabled,
|
||||
initialValues,
|
||||
onValuesChange,
|
||||
}: DeployNodeConfigForm1PanelConsoleConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
autoRestart: z.boolean().nullish(),
|
||||
});
|
||||
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="autoRestart" label={t("workflow_node.deploy.form.1panel_console_auto_restart.label")} rules={[formRule]}>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default DeployNodeConfigForm1PanelConsoleConfig;
|
||||
@@ -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 DeployNodeConfigForm1PanelSiteConfigFieldValues = Nullish<{
|
||||
websiteId: string | number;
|
||||
}>;
|
||||
|
||||
export type DeployNodeConfigForm1PanelSiteConfigProps = {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: DeployNodeConfigForm1PanelSiteConfigFieldValues;
|
||||
onValuesChange?: (values: DeployNodeConfigForm1PanelSiteConfigFieldValues) => void;
|
||||
};
|
||||
|
||||
const initFormModel = (): DeployNodeConfigForm1PanelSiteConfigFieldValues => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const DeployNodeConfigForm1PanelSiteConfig = ({
|
||||
form: formInst,
|
||||
formName,
|
||||
disabled,
|
||||
initialValues,
|
||||
onValuesChange,
|
||||
}: DeployNodeConfigForm1PanelSiteConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
websiteId: z.union([z.string(), z.number()]).refine((v) => {
|
||||
return /^\d+$/.test(v + "") && +v > 0;
|
||||
}, t("workflow_node.deploy.form.1panel_site_website_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="websiteId"
|
||||
label={t("workflow_node.deploy.form.1panel_site_website_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("workflow_node.deploy.form.1panel_site_website_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input type="number" placeholder={t("workflow_node.deploy.form.1panel_site_website_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default DeployNodeConfigForm1PanelSiteConfig;
|
||||
Reference in New Issue
Block a user