feat: add 1panel deployer

This commit is contained in:
Fu Diwei
2025-03-07 15:43:40 +08:00
parent 6ccbdeb89a
commit 29dda4ec66
32 changed files with 1098 additions and 10 deletions

View File

@@ -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:

View File

@@ -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;

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 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;