diff --git a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderLocal.tsx b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderLocal.tsx index 694b59443..436ab595d 100644 --- a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderLocal.tsx +++ b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderLocal.tsx @@ -1,6 +1,6 @@ import { getI18n, useTranslation } from "react-i18next"; -import { IconBulb, IconChevronDown } from "@tabler/icons-react"; -import { Button, Divider, Form, Input, Popover, Select, Space } from "antd"; +import { IconBulb, IconChevronDown, IconDice6 } from "@tabler/icons-react"; +import { Button, Divider, Form, Input, Popover, Select, Space, Tooltip } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; @@ -9,6 +9,7 @@ import PresetScriptTemplatesPopselect from "@/components/preset/PresetScriptTemp import Show from "@/components/Show"; import Tips from "@/components/Tips"; import { CERTIFICATE_FORMATS } from "@/domain/certificate"; +import { randomString } from "@/utils/random"; import { useFormNestedFieldsContext } from "./_context"; @@ -172,6 +173,21 @@ const BizDeployNodeConfigFieldsProviderLocal = () => { } }; + const handleRandomPfxPasswordClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "pfxPassword"], password); + }; + + const handleRandomJksKeypassClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "jksKeypass"], password); + }; + + const handleRandomJksStorepassClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "jksStorepass"], password); + }; + const handlePresetPreScriptClick = (key: string) => { switch (key) { case "sh_backup_files": @@ -281,13 +297,19 @@ const BizDeployNodeConfigFieldsProviderLocal = () => { } > - + + + + + + + + @@ -303,23 +325,35 @@ const BizDeployNodeConfigFieldsProviderLocal = () => { } > - + + + + + + + + } > - + + + + + + + + diff --git a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderS3.tsx b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderS3.tsx index d75a168fe..48cc121e0 100644 --- a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderS3.tsx +++ b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderS3.tsx @@ -1,10 +1,12 @@ import { getI18n, useTranslation } from "react-i18next"; -import { Form, Input, Select } from "antd"; +import { IconDice6 } from "@tabler/icons-react"; +import { Button, Form, Input, Select, Space, Tooltip } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import Show from "@/components/Show"; import { CERTIFICATE_FORMATS } from "@/domain/certificate"; +import { randomString } from "@/utils/random"; import { useFormNestedFieldsContext } from "./_context"; @@ -56,6 +58,21 @@ const BizDeployNodeConfigFieldsProviderS3 = () => { } }; + const handleRandomPfxPasswordClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "pfxPassword"], password); + }; + + const handleRandomJksKeypassClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "jksKeypass"], password); + }; + + const handleRandomJksStorepassClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "jksStorepass"], password); + }; + return ( <> { } > - + + + + + + + + @@ -159,23 +182,35 @@ const BizDeployNodeConfigFieldsProviderS3 = () => { } > - + + + + + + + + } > - + + + + + + + + diff --git a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderSSH.tsx b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderSSH.tsx index 58b636320..e92bfdc18 100644 --- a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderSSH.tsx +++ b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderSSH.tsx @@ -1,6 +1,6 @@ import { getI18n, useTranslation } from "react-i18next"; -import { IconBulb, IconChevronDown } from "@tabler/icons-react"; -import { Button, Divider, Form, Input, Popover, Select, Space, Switch } from "antd"; +import { IconBulb, IconChevronDown, IconDice6 } from "@tabler/icons-react"; +import { Button, Divider, Form, Input, Popover, Select, Space, Switch, Tooltip } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; @@ -8,6 +8,7 @@ import CodeTextInput from "@/components/CodeTextInput"; import PresetScriptTemplatesPopselect from "@/components/preset/PresetScriptTemplatesPopselect"; import Show from "@/components/Show"; import { CERTIFICATE_FORMATS } from "@/domain/certificate"; +import { randomString } from "@/utils/random"; import { useFormNestedFieldsContext } from "./_context"; import { initPresetScript as _initPresetScript } from "./BizDeployNodeConfigFieldsProviderLocal"; @@ -205,6 +206,21 @@ const BizDeployNodeConfigFieldsProviderSSH = () => { } }; + const handleRandomPfxPasswordClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "pfxPassword"], password); + }; + + const handleRandomJksKeypassClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "jksKeypass"], password); + }; + + const handleRandomJksStorepassClick = () => { + const password = randomString(); + formInst.setFieldValue([parentNamePath, "jksStorepass"], password); + }; + const handlePresetPreScriptClick = (key: string) => { switch (key) { case "sh_backup_files": @@ -331,13 +347,19 @@ const BizDeployNodeConfigFieldsProviderSSH = () => { } > - + + + + + + + + @@ -353,23 +375,35 @@ const BizDeployNodeConfigFieldsProviderSSH = () => { } > - + + + + + + + + } > - + + + + + + + + diff --git a/ui/src/components/workflow/designer/forms/StartNodeConfigForm.tsx b/ui/src/components/workflow/designer/forms/StartNodeConfigForm.tsx index 06cb7b328..ca7ee181c 100644 --- a/ui/src/components/workflow/designer/forms/StartNodeConfigForm.tsx +++ b/ui/src/components/workflow/designer/forms/StartNodeConfigForm.tsx @@ -2,7 +2,7 @@ import { getI18n, useTranslation } from "react-i18next"; import { type FlowNodeEntity } from "@flowgram.ai/fixed-layout-editor"; import { IconDice6 } from "@tabler/icons-react"; -import { type AnchorProps, Button, Form, type FormInstance, Input, Radio, Space } from "antd"; +import { type AnchorProps, Button, Form, type FormInstance, Input, Radio, Space, Tooltip } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import dayjs from "dayjs"; import { z } from "zod"; @@ -95,9 +95,11 @@ const StartNodeConfigForm = ({ node, ...props }: StartNodeConfigFormProps) => { - + + + diff --git a/ui/src/i18n/locales/en/nls.common.json b/ui/src/i18n/locales/en/nls.common.json index 7c9db82d0..92beb5fee 100644 --- a/ui/src/i18n/locales/en/nls.common.json +++ b/ui/src/i18n/locales/en/nls.common.json @@ -25,6 +25,7 @@ "common.text.operation_confirm": "Operation confirm", "common.text.operation_succeeded": "Operation succeeded", "common.text.operation_failed": "Operation failed", + "common.text.random_roll": "Random roll", "common.text.request_error": "Request error", "common.text.saved": "Saved successfully", "common.text.saving": "Saving ...", diff --git a/ui/src/i18n/locales/zh/nls.common.json b/ui/src/i18n/locales/zh/nls.common.json index 23385d8bb..056d1183c 100644 --- a/ui/src/i18n/locales/zh/nls.common.json +++ b/ui/src/i18n/locales/zh/nls.common.json @@ -25,6 +25,7 @@ "common.text.operation_confirm": "操作确认", "common.text.operation_succeeded": "操作成功", "common.text.operation_failed": "操作失败", + "common.text.random_roll": "随机生成", "common.text.request_error": "请求错误", "common.text.saved": "已保存", "common.text.saving": "保存中 ……", diff --git a/ui/src/utils/random.ts b/ui/src/utils/random.ts new file mode 100644 index 000000000..02c324bfa --- /dev/null +++ b/ui/src/utils/random.ts @@ -0,0 +1,24 @@ +export function randomString(): string; +export function randomString(length: number): string; +export function randomString(options: { length?: number; alphabet?: string }): string; +export function randomString(arg?: number | { length?: number; alphabet?: string }): string { + const DEFAULT_LENGTH = 32; + const DEFAULT_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + + let length = DEFAULT_LENGTH; + let alphabet = DEFAULT_ALPHABET; + + if (typeof arg === "number") { + length = arg; + } else if (arg && typeof arg === "object") { + if (arg.length != null) { + length = arg.length; + } + if (arg.alphabet != null) { + alphabet = arg.alphabet; + } + } + + const randomBytes = crypto.getRandomValues(new Uint8Array(length)); + return Array.from(randomBytes, (b) => alphabet[b % alphabet.length]).join(""); +}