fix(userActions): update error messages to include dynamic max length and improve validation logic

This commit is contained in:
twwu 2026-01-28 11:51:08 +08:00
parent 91f118c82c
commit b3be035c64
4 changed files with 10 additions and 8 deletions

View File

@ -39,7 +39,7 @@ const InputField: React.FC<InputFieldProps> = ({
return false
if (name.includes(' '))
return false
return /^(?:[a-z_]\w{0,29}){1,10}$/.test(name)
return /^[a-z_]\w{0,29}$/.test(name)
}, [tempPayload.output_variable_name])
const handleSave = useCallback(() => {
if (!nameValid)

View File

@ -46,13 +46,15 @@ const UserActionItem: FC<UserActionItemProps> = ({
})
.join('')
if (sanitized !== withUnderscores)
if (sanitized !== withUnderscores) {
Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.actionIdFormatTip`, { ns: 'workflow' }) })
return
}
// Limit to 20 characters
if (sanitized.length > ACTION_ID_MAX_LENGTH) {
sanitized = sanitized.slice(0, ACTION_ID_MAX_LENGTH)
Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.actionIdTooLong`, { ns: 'workflow' }) })
Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.actionIdTooLong`, { ns: 'workflow', maxLength: ACTION_ID_MAX_LENGTH }) })
}
if (sanitized)
@ -63,7 +65,7 @@ const UserActionItem: FC<UserActionItemProps> = ({
let value = e.target.value
if (value.length > BUTTON_TEXT_MAX_LENGTH) {
value = value.slice(0, BUTTON_TEXT_MAX_LENGTH)
Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.buttonTextTooLong`, { ns: 'workflow' }) })
Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.buttonTextTooLong`, { ns: 'workflow', maxLength: BUTTON_TEXT_MAX_LENGTH }) })
}
onChange({ ...data, title: value })
}

View File

@ -593,10 +593,10 @@
"nodes.humanInput.timeout.hours": "Hours",
"nodes.humanInput.timeout.title": "Timeout",
"nodes.humanInput.userActions.actionIdFormatTip": "Action ID must start with a letter or underscores, followed by letters, numbers, or underscores",
"nodes.humanInput.userActions.actionIdTooLong": "Action ID must be 20 characters or less",
"nodes.humanInput.userActions.actionIdTooLong": "Action ID must be {{maxLength}} characters or less",
"nodes.humanInput.userActions.actionNamePlaceholder": "Action Name",
"nodes.humanInput.userActions.buttonTextPlaceholder": "Button display Text",
"nodes.humanInput.userActions.buttonTextTooLong": "Button text must be 40 characters or less",
"nodes.humanInput.userActions.buttonTextTooLong": "Button text must be {{maxLength}} characters or less",
"nodes.humanInput.userActions.chooseStyle": "Choose a button style",
"nodes.humanInput.userActions.emptyTip": "Click the '+' button to add user actions",
"nodes.humanInput.userActions.title": "User Actions",

View File

@ -593,10 +593,10 @@
"nodes.humanInput.timeout.hours": "小时",
"nodes.humanInput.timeout.title": "超时设置",
"nodes.humanInput.userActions.actionIdFormatTip": "操作 ID 必须以字母或下划线开头,后跟字母、数字或下划线",
"nodes.humanInput.userActions.actionIdTooLong": "操作 ID 不能超过 20 个字符",
"nodes.humanInput.userActions.actionIdTooLong": "操作 ID 不能超过 {{maxLength}} 个字符",
"nodes.humanInput.userActions.actionNamePlaceholder": "操作名称",
"nodes.humanInput.userActions.buttonTextPlaceholder": "按钮显示文本",
"nodes.humanInput.userActions.buttonTextTooLong": "按钮文本不能超过 40 个字符",
"nodes.humanInput.userActions.buttonTextTooLong": "按钮文本不能超过 {{maxLength}} 个字符",
"nodes.humanInput.userActions.chooseStyle": "选择按钮样式",
"nodes.humanInput.userActions.emptyTip": "点击 '+' 按钮添加用户操作",
"nodes.humanInput.userActions.title": "用户操作",