refactor: clean code
This commit is contained in:
@@ -17,7 +17,7 @@ export type AccessForm1PanelConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessForm1PanelConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:20410/",
|
||||
serverUrl: "http://<your-host-addr>:20410/",
|
||||
apiVersion: "v1",
|
||||
apiKey: "",
|
||||
};
|
||||
@@ -27,7 +27,7 @@ const AccessForm1PanelConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiVersion: z.string().nonempty(t("access.form.1panel_api_version.placeholder")),
|
||||
apiKey: z
|
||||
.string()
|
||||
@@ -51,8 +51,8 @@ const AccessForm1PanelConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.1panel_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.1panel_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.1panel_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.1panel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiVersion" label={t("access.form.1panel_api_version.label")} rules={[formRule]}>
|
||||
@@ -68,10 +68,10 @@ const AccessForm1PanelConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.1panel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.1panel_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.1panel_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.1panel_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormBaotaPanelConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormBaotaPanelConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:8888/",
|
||||
serverUrl: "http://<your-host-addr>:8888/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
@@ -26,7 +26,7 @@ const AccessFormBaotaPanelConfig = ({ form: formInst, formName, disabled, initia
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.baotapanel_api_key.placeholder")).trim(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
@@ -45,8 +45,8 @@ const AccessFormBaotaPanelConfig = ({ form: formInst, formName, disabled, initia
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.baotapanel_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.baotapanel_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.baotapanel_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.baotapanel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -58,10 +58,10 @@ const AccessFormBaotaPanelConfig = ({ form: formInst, formName, disabled, initia
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baotapanel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.baotapanel_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.baotapanel_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.baotapanel_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormBaotaWAFConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormBaotaWAFConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:8379/",
|
||||
serverUrl: "http://<your-host-addr>:8379/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
@@ -26,7 +26,7 @@ const AccessFormBaotaWAFConfig = ({ form: formInst, formName, disabled, initialV
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.baotawaf_api_key.placeholder")).trim(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
@@ -45,8 +45,8 @@ const AccessFormBaotaWAFConfig = ({ form: formInst, formName, disabled, initialV
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.baotawaf_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.baotawaf_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.baotawaf_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.baotawaf_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -58,10 +58,10 @@ const AccessFormBaotaWAFConfig = ({ form: formInst, formName, disabled, initialV
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baotawaf_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.baotawaf_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.baotawaf_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.baotawaf_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormCdnflyConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormCdnflyConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:88/",
|
||||
serverUrl: "http://<your-host-addr>:88/",
|
||||
apiKey: "",
|
||||
apiSecret: "",
|
||||
};
|
||||
@@ -27,7 +27,7 @@ const AccessFormCdnflyConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.cdnfly_api_key.placeholder"))
|
||||
@@ -55,8 +55,8 @@ const AccessFormCdnflyConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.cdnfly_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.cdnfly_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.cdnfly_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.cdnfly_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -77,10 +77,10 @@ const AccessFormCdnflyConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cdnfly_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.cdnfly_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.cdnfly_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.cdnfly_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormFlexCDNConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormFlexCDNConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:8000/",
|
||||
serverUrl: "http://<your-host-addr>:8000/",
|
||||
apiRole: "user",
|
||||
accessKeyId: "",
|
||||
accessKey: "",
|
||||
@@ -28,7 +28,7 @@ const AccessFormFlexCDNConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
role: z.union([z.literal("user"), z.literal("admin")], {
|
||||
message: t("access.form.flexcdn_api_role.placeholder"),
|
||||
}),
|
||||
@@ -51,8 +51,8 @@ const AccessFormFlexCDNConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.flexcdn_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.flexcdn_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.flexcdn_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.flexcdn_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiRole" label={t("access.form.flexcdn_api_role.label")} rules={[formRule]}>
|
||||
@@ -77,10 +77,10 @@ const AccessFormFlexCDNConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.flexcdn_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.flexcdn_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.flexcdn_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.flexcdn_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormGoEdgeConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormGoEdgeConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:7788/",
|
||||
serverUrl: "http://<your-host-addr>:7788/",
|
||||
apiRole: "user",
|
||||
accessKeyId: "",
|
||||
accessKey: "",
|
||||
@@ -28,7 +28,7 @@ const AccessFormGoEdgeConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
role: z.union([z.literal("user"), z.literal("admin")], {
|
||||
message: t("access.form.goedge_api_role.placeholder"),
|
||||
}),
|
||||
@@ -51,8 +51,8 @@ const AccessFormGoEdgeConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.goedge_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.goedge_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.goedge_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.goedge_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiRole" label={t("access.form.goedge_api_role.label")} rules={[formRule]}>
|
||||
@@ -77,10 +77,10 @@ const AccessFormGoEdgeConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.goedge_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.goedge_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.goedge_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.goedge_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormLeCDNConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormLeCDNConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:5090/",
|
||||
serverUrl: "http://<your-host-addr>:5090/",
|
||||
apiVersion: "v3",
|
||||
apiRole: "user",
|
||||
username: "",
|
||||
@@ -29,7 +29,7 @@ const AccessFormLeCDNConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
role: z.union([z.literal("client"), z.literal("master")], {
|
||||
message: t("access.form.lecdn_api_role.placeholder"),
|
||||
}),
|
||||
@@ -52,8 +52,8 @@ const AccessFormLeCDNConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.lecdn_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.lecdn_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.lecdn_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.lecdn_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiVersion" label={t("access.form.lecdn_api_version.label")} rules={[formRule]}>
|
||||
@@ -72,10 +72,10 @@ const AccessFormLeCDNConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.lecdn_password.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.lecdn_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.lecdn_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.lecdn_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormPowerDNSConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormPowerDNSConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:8082/",
|
||||
serverUrl: "http://<your-host-addr>:8082/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
@@ -26,7 +26,7 @@ const AccessFormPowerDNSConfig = ({ form: formInst, formName, disabled, initialV
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.powerdns_api_key.placeholder"))
|
||||
@@ -49,8 +49,8 @@ const AccessFormPowerDNSConfig = ({ form: formInst, formName, disabled, initialV
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.powerdns_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.powerdns_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.powerdns_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.powerdns_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -62,10 +62,10 @@ const AccessFormPowerDNSConfig = ({ form: formInst, formName, disabled, initialV
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.powerdns_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.powerdns_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.powerdns_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.powerdns_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormProxmoxVEConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormProxmoxVEConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:8006/",
|
||||
serverUrl: "http://<your-host-addr>:8006/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
@@ -26,7 +26,7 @@ const AccessFormProxmoxVEConfig = ({ form: formInst, formName, disabled, initial
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z.string().nonempty(t("access.form.proxmoxve_api_token.placeholder")).trim(),
|
||||
apiTokenSecret: z.string().nullish(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
@@ -46,8 +46,8 @@ const AccessFormProxmoxVEConfig = ({ form: formInst, formName, disabled, initial
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.proxmoxve_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.proxmoxve_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.proxmoxve_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.proxmoxve_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -68,10 +68,10 @@ const AccessFormProxmoxVEConfig = ({ form: formInst, formName, disabled, initial
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.proxmoxve_api_token_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.proxmoxve_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.proxmoxve_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.proxmoxve_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormRatPanelConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormRatPanelConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:8888/",
|
||||
serverUrl: "http://<your-host-addr>:8888/",
|
||||
accessTokenId: 1,
|
||||
accessToken: "",
|
||||
};
|
||||
@@ -27,7 +27,7 @@ const AccessFormRatPanelConfig = ({ form: formInst, formName, disabled, initialV
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
accessTokenId: z.preprocess((v) => Number(v), z.number().positive(t("access.form.ratpanel_access_token_id.placeholder"))),
|
||||
accessToken: z.string().nonempty(t("access.form.ratpanel_access_token.placeholder")).trim(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
@@ -47,8 +47,8 @@ const AccessFormRatPanelConfig = ({ form: formInst, formName, disabled, initialV
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.ratpanel_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.ratpanel_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.ratpanel_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.ratpanel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -69,10 +69,10 @@ const AccessFormRatPanelConfig = ({ form: formInst, formName, disabled, initialV
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ratpanel_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.ratpanel_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.ratpanel_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.ratpanel_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,7 @@ export type AccessFormSafeLineConfigProps = {
|
||||
|
||||
const initFormModel = (): AccessFormSafeLineConfigFieldValues => {
|
||||
return {
|
||||
apiUrl: "http://<your-host-addr>:9443/",
|
||||
serverUrl: "http://<your-host-addr>:9443/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
@@ -26,7 +26,7 @@ const AccessFormSafeLineConfig = ({ form: formInst, formName, disabled, initialV
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
serverUrl: z.string().url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.safeline_api_token.placeholder"))
|
||||
@@ -49,8 +49,8 @@ const AccessFormSafeLineConfig = ({ form: formInst, formName, disabled, initialV
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiUrl" label={t("access.form.safeline_api_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.safeline_api_url.placeholder")} />
|
||||
<Form.Item name="serverUrl" label={t("access.form.safeline_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.safeline_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -62,10 +62,10 @@ const AccessFormSafeLineConfig = ({ form: formInst, formName, disabled, initialV
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.safeline_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.safeline_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.safeline_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.safeline_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -362,10 +362,10 @@ const AccessFormWebhookConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.webhook_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.webhook_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.webhook_allow_insecure_conns.switch.off")}
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { memo, useRef } from "react";
|
||||
import { memo, useMemo, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
CloseCircleOutlined as CloseCircleOutlinedIcon,
|
||||
EllipsisOutlined as EllipsisOutlinedIcon,
|
||||
FormOutlined as FormOutlinedIcon,
|
||||
MergeOutlined as MergeOutlinedIcon,
|
||||
MoreOutlined as MoreOutlinedIcon,
|
||||
} from "@ant-design/icons";
|
||||
import { useControllableValue } from "ahooks";
|
||||
import { Button, Card, Drawer, Dropdown, Input, type InputRef, Modal, Popover, Space } from "antd";
|
||||
import { Button, Card, Drawer, Dropdown, Input, type InputRef, type MenuProps, Modal, Popover, Space } from "antd";
|
||||
import { produce } from "immer";
|
||||
import { isEqual } from "radash";
|
||||
|
||||
@@ -59,12 +60,13 @@ const SharedNodeTitle = ({ className, style, node, disabled }: SharedNodeTitlePr
|
||||
type SharedNodeMenuProps = SharedNodeProps & {
|
||||
branchId?: string;
|
||||
branchIndex?: number;
|
||||
menus?: Array<"rename" | "duplicate" | "remove">;
|
||||
trigger: React.ReactNode;
|
||||
afterUpdate?: () => void;
|
||||
afterDelete?: () => void;
|
||||
};
|
||||
|
||||
const isBranchingNode = (node: WorkflowNode) => {
|
||||
const isNodeBranchLike = (node: WorkflowNode) => {
|
||||
return (
|
||||
node.type === WorkflowNodeType.Branch ||
|
||||
node.type === WorkflowNodeType.Condition ||
|
||||
@@ -74,7 +76,11 @@ const isBranchingNode = (node: WorkflowNode) => {
|
||||
);
|
||||
};
|
||||
|
||||
const SharedNodeMenu = ({ trigger, node, disabled, branchId, branchIndex, afterUpdate, afterDelete }: SharedNodeMenuProps) => {
|
||||
const isNodeReadOnly = (node: WorkflowNode) => {
|
||||
return node.type === WorkflowNodeType.Start || node.type === WorkflowNodeType.End;
|
||||
};
|
||||
|
||||
const SharedNodeMenu = ({ menus, trigger, node, disabled, branchId, branchIndex, afterUpdate, afterDelete }: SharedNodeMenuProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { updateNode, removeNode, removeBranch } = useWorkflowStore(useZustandShallowSelector(["updateNode", "removeNode", "removeBranch"]));
|
||||
@@ -101,7 +107,7 @@ const SharedNodeMenu = ({ trigger, node, disabled, branchId, branchIndex, afterU
|
||||
};
|
||||
|
||||
const handleDeleteClick = async () => {
|
||||
if (isBranchingNode(node)) {
|
||||
if (isNodeBranchLike(node)) {
|
||||
await removeBranch(branchId!, branchIndex!);
|
||||
} else {
|
||||
await removeNode(node.id);
|
||||
@@ -110,56 +116,82 @@ const SharedNodeMenu = ({ trigger, node, disabled, branchId, branchIndex, afterU
|
||||
afterDelete?.();
|
||||
};
|
||||
|
||||
const menuItems = useMemo(() => {
|
||||
let temp = [
|
||||
{
|
||||
key: "rename",
|
||||
disabled: disabled,
|
||||
label: isNodeBranchLike(node) ? t("workflow_node.action.rename_branch") : t("workflow_node.action.rename_node"),
|
||||
icon: <FormOutlinedIcon />,
|
||||
onClick: () => {
|
||||
nameRef.current = node.name;
|
||||
|
||||
const dialog = modalApi.confirm({
|
||||
title: isNodeBranchLike(node) ? t("workflow_node.action.rename_branch") : t("workflow_node.action.rename_node"),
|
||||
content: (
|
||||
<div className="pb-2 pt-4">
|
||||
<Input
|
||||
ref={nameInputRef}
|
||||
autoFocus
|
||||
defaultValue={node.name}
|
||||
onChange={(e) => (nameRef.current = e.target.value)}
|
||||
onPressEnter={async () => {
|
||||
await handleRenameConfirm();
|
||||
dialog.destroy();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
icon: null,
|
||||
okText: t("common.button.save"),
|
||||
onOk: handleRenameConfirm,
|
||||
});
|
||||
setTimeout(() => nameInputRef.current?.focus(), 1);
|
||||
},
|
||||
},
|
||||
// {
|
||||
// key: "duplicate",
|
||||
// disabled: disabled || isNodeReadOnly(node),
|
||||
// label: isNodeBranchLike(node) ? t("workflow_node.action.duplicate_branch") : t("workflow_node.action.duplicate_node"),
|
||||
// icon: <MergeOutlinedIcon />,
|
||||
// },
|
||||
{
|
||||
type: "divider",
|
||||
},
|
||||
{
|
||||
key: "remove",
|
||||
disabled: disabled || isNodeReadOnly(node),
|
||||
label: isNodeBranchLike(node) ? t("workflow_node.action.remove_branch") : t("workflow_node.action.remove_node"),
|
||||
icon: <CloseCircleOutlinedIcon />,
|
||||
danger: true,
|
||||
onClick: handleDeleteClick,
|
||||
},
|
||||
] satisfies MenuProps["items"];
|
||||
|
||||
if (menus) {
|
||||
temp = temp.filter((item) => item.type === "divider" || menus.includes(item.key as "rename" | "remove"));
|
||||
temp = temp.filter((item, index, array) => {
|
||||
if (item.type !== "divider") return true;
|
||||
return index === 0 || array[index - 1].type !== "divider";
|
||||
});
|
||||
if (temp[0]?.type === "divider") {
|
||||
temp.shift();
|
||||
}
|
||||
if (temp[temp.length - 1]?.type === "divider") {
|
||||
temp.pop();
|
||||
}
|
||||
}
|
||||
|
||||
return temp;
|
||||
}, [disabled, node]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{ModelContextHolder}
|
||||
|
||||
<Dropdown
|
||||
menu={{
|
||||
items: [
|
||||
{
|
||||
key: "rename",
|
||||
disabled: disabled,
|
||||
label: isBranchingNode(node) ? t("workflow_node.action.rename_branch") : t("workflow_node.action.rename_node"),
|
||||
icon: <FormOutlinedIcon />,
|
||||
onClick: () => {
|
||||
nameRef.current = node.name;
|
||||
|
||||
const dialog = modalApi.confirm({
|
||||
title: isBranchingNode(node) ? t("workflow_node.action.rename_branch") : t("workflow_node.action.rename_node"),
|
||||
content: (
|
||||
<div className="pb-2 pt-4">
|
||||
<Input
|
||||
ref={nameInputRef}
|
||||
autoFocus
|
||||
defaultValue={node.name}
|
||||
onChange={(e) => (nameRef.current = e.target.value)}
|
||||
onPressEnter={async () => {
|
||||
await handleRenameConfirm();
|
||||
dialog.destroy();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
icon: null,
|
||||
okText: t("common.button.save"),
|
||||
onOk: handleRenameConfirm,
|
||||
});
|
||||
setTimeout(() => nameInputRef.current?.focus(), 1);
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "divider",
|
||||
},
|
||||
{
|
||||
key: "remove",
|
||||
disabled: disabled || node.type === WorkflowNodeType.Start,
|
||||
label: isBranchingNode(node) ? t("workflow_node.action.remove_branch") : t("workflow_node.action.remove_node"),
|
||||
icon: <CloseCircleOutlinedIcon />,
|
||||
danger: true,
|
||||
onClick: handleDeleteClick,
|
||||
},
|
||||
],
|
||||
items: menuItems,
|
||||
}}
|
||||
trigger={["click"]}
|
||||
>
|
||||
@@ -264,7 +296,6 @@ const SharedNodeConfigDrawer = ({
|
||||
|
||||
const { promise, resolve, reject } = Promise.withResolvers();
|
||||
if (changed) {
|
||||
console.log(oldValues, newValues);
|
||||
modalApi.confirm({
|
||||
title: t("common.text.operation_confirm"),
|
||||
content: t("workflow_node.unsaved_changes.confirm"),
|
||||
@@ -288,6 +319,7 @@ const SharedNodeConfigDrawer = ({
|
||||
destroyOnHidden
|
||||
extra={
|
||||
<SharedNodeMenu
|
||||
menus={["rename", "remove"]}
|
||||
node={node}
|
||||
disabled={disabled}
|
||||
trigger={<Button icon={<EllipsisOutlinedIcon />} type="text" />}
|
||||
|
||||
Reference in New Issue
Block a user