From 988f600d226aae4404c598b5b5deb8e430bc4ad8 Mon Sep 17 00:00:00 2001 From: Divyanshu patil Date: Fri, 21 Nov 2025 16:44:38 +0530 Subject: [PATCH 1/2] fix: added url validation in AddUrlModal, todo: translations --- .../messageBox/AddLinkComposerActionModal.tsx | 24 +++++++++++++++---- packages/i18n/src/locales/en.i18n.json | 2 ++ packages/i18n/src/locales/es.i18n.json | 2 ++ packages/i18n/src/locales/hi-IN.i18n.json | 3 +++ packages/i18n/src/locales/pt-BR.i18n.json | 2 ++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/ui-message/client/messageBox/AddLinkComposerActionModal.tsx b/apps/meteor/app/ui-message/client/messageBox/AddLinkComposerActionModal.tsx index ce75e12ee68df..fdef7a3da5857 100644 --- a/apps/meteor/app/ui-message/client/messageBox/AddLinkComposerActionModal.tsx +++ b/apps/meteor/app/ui-message/client/messageBox/AddLinkComposerActionModal.tsx @@ -1,4 +1,4 @@ -import { Field, FieldGroup, TextInput, FieldLabel, FieldRow, Box } from '@rocket.chat/fuselage'; +import { Field, FieldGroup, TextInput, FieldLabel, FieldRow, Box, FieldError } from '@rocket.chat/fuselage'; import { GenericModal } from '@rocket.chat/ui-client'; import { useEffect, useId } from 'react'; import { useForm, Controller } from 'react-hook-form'; @@ -15,8 +15,8 @@ const AddLinkComposerActionModal = ({ selectedText, onClose, onConfirm }: AddLin const textField = useId(); const urlField = useId(); - const { handleSubmit, setFocus, control } = useForm({ - mode: 'onBlur', + const { handleSubmit, setFocus, control, formState } = useForm({ + mode: 'onChange', defaultValues: { text: selectedText || '', url: '', @@ -40,6 +40,7 @@ const AddLinkComposerActionModal = ({ selectedText, onClose, onConfirm }: AddLin confirmText={t('Add')} onCancel={onClose} wrapperFunction={(props) => void submit(e)} {...props} />} + confirmDisabled={!formState.isValid} title={t('Add_link')} > @@ -52,8 +53,23 @@ const AddLinkComposerActionModal = ({ selectedText, onClose, onConfirm }: AddLin {t('URL')} - } /> + } + /> + {formState.errors.url?.message} diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index 9636df6ef6a9e..1fc6a947b0294 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -5365,6 +5365,8 @@ "UI_Use_Real_Name": "Use Real Name", "URL": "URL", "URLs": "URLs", + "URL_is_required": "URL is required", + "URL_must_start_with_'http://'_or_'https://'": "URL must start with 'http://' or 'https://'", "UTC_Timezone": "UTC Timezone", "UTF8_Channel_Names_Validation": "UTF8 Channel Names Validation", "UTF8_Channel_Names_Validation_Description": "RegExp that will be used to validate channel names", diff --git a/packages/i18n/src/locales/es.i18n.json b/packages/i18n/src/locales/es.i18n.json index 7315c66c19ee0..09162215eba3e 100644 --- a/packages/i18n/src/locales/es.i18n.json +++ b/packages/i18n/src/locales/es.i18n.json @@ -3891,6 +3891,8 @@ "UI_Use_Name_Avatar": "Usar iniciales del nombre completo para generar un avatar por defecto", "UI_Use_Real_Name": "Usar nombre real", "URL": "URL", + "URL_is_required": "", + "URL_must_start_with_'http://'_or_'https://'": "La URL debe comenzar con 'http://' o 'https://'", "UTC_Timezone": "Zona horaria UTC", "UTF8_Channel_Names_Validation": "Validación de nombres de Channel UTF8", "UTF8_Channel_Names_Validation_Description": "Regex que se usará para validar los nombres de canal", diff --git a/packages/i18n/src/locales/hi-IN.i18n.json b/packages/i18n/src/locales/hi-IN.i18n.json index 6deba0bc38106..59220309cc00d 100644 --- a/packages/i18n/src/locales/hi-IN.i18n.json +++ b/packages/i18n/src/locales/hi-IN.i18n.json @@ -4453,6 +4453,7 @@ "Test_Connection": "परीक्षण कनेक्शन", "Test_Desktop_Notifications": "डेस्कटॉप सूचनाओं का परीक्षण करें", "Test_LDAP_Search": "एलडीएपी खोज का परीक्षण करें", + "Text": "टेक्स्ट", "Texts": "ग्रंथों", "Thank_You_For_Choosing_RocketChat": "रॉकेट.चैट चुनने के लिए धन्यवाद!", "Thank_you_exclamation_mark": "धन्यवाद!", @@ -4647,6 +4648,8 @@ "UI_Use_Real_Name": "वास्तविक नाम का प्रयोग करें", "URL": "यूआरएल", "URLs": "यूआरएल", + "URL_is_required": "", + "URL_must_start_with_'http://'_or_'https://'": "यूआरएल की शुरुआत 'http://' या 'https://' से होनी चाहिए।", "UTC_Timezone": "यूटीसी समय क्षेत्र", "UTF8_Channel_Names_Validation": "UTF8 चैनल नाम सत्यापन", "UTF8_Channel_Names_Validation_Description": "रेगएक्सपी जिसका उपयोग चैनल नामों को मान्य करने के लिए किया जाएगा", diff --git a/packages/i18n/src/locales/pt-BR.i18n.json b/packages/i18n/src/locales/pt-BR.i18n.json index 830bc77e020a0..02284d0537edc 100644 --- a/packages/i18n/src/locales/pt-BR.i18n.json +++ b/packages/i18n/src/locales/pt-BR.i18n.json @@ -5214,6 +5214,8 @@ "UI_Use_Real_Name": "Usar o nome verdadeiro", "URL": "URL", "URLs": "URLs", + "URL_is_required": "", + "URL_must_start_with_'http://'_or_'https://'": "A URL deve começar com 'http://' ou 'https://'", "UTC_Timezone": "Fuso horário UTC", "UTF8_Channel_Names_Validation": "Validação de nomes de canal UTF8", "UTF8_Channel_Names_Validation_Description": "RegExp que será usado para validar nomes de canais", From 3e0de4782bd84549c529eb0ac77807c90d936403 Mon Sep 17 00:00:00 2001 From: Divyanshu patil Date: Fri, 21 Nov 2025 18:12:14 +0530 Subject: [PATCH 2/2] i18n: added translations --- packages/i18n/src/locales/es.i18n.json | 2 +- packages/i18n/src/locales/hi-IN.i18n.json | 2 +- packages/i18n/src/locales/pt-BR.i18n.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/i18n/src/locales/es.i18n.json b/packages/i18n/src/locales/es.i18n.json index 09162215eba3e..995903808628b 100644 --- a/packages/i18n/src/locales/es.i18n.json +++ b/packages/i18n/src/locales/es.i18n.json @@ -3891,7 +3891,7 @@ "UI_Use_Name_Avatar": "Usar iniciales del nombre completo para generar un avatar por defecto", "UI_Use_Real_Name": "Usar nombre real", "URL": "URL", - "URL_is_required": "", + "URL_is_required": "La URL es obligatoria", "URL_must_start_with_'http://'_or_'https://'": "La URL debe comenzar con 'http://' o 'https://'", "UTC_Timezone": "Zona horaria UTC", "UTF8_Channel_Names_Validation": "Validación de nombres de Channel UTF8", diff --git a/packages/i18n/src/locales/hi-IN.i18n.json b/packages/i18n/src/locales/hi-IN.i18n.json index 59220309cc00d..43b85f6981a58 100644 --- a/packages/i18n/src/locales/hi-IN.i18n.json +++ b/packages/i18n/src/locales/hi-IN.i18n.json @@ -4648,7 +4648,7 @@ "UI_Use_Real_Name": "वास्तविक नाम का प्रयोग करें", "URL": "यूआरएल", "URLs": "यूआरएल", - "URL_is_required": "", + "URL_is_required": "यूआरएल आवश्यक है", "URL_must_start_with_'http://'_or_'https://'": "यूआरएल की शुरुआत 'http://' या 'https://' से होनी चाहिए।", "UTC_Timezone": "यूटीसी समय क्षेत्र", "UTF8_Channel_Names_Validation": "UTF8 चैनल नाम सत्यापन", diff --git a/packages/i18n/src/locales/pt-BR.i18n.json b/packages/i18n/src/locales/pt-BR.i18n.json index 02284d0537edc..c15f94fdca57b 100644 --- a/packages/i18n/src/locales/pt-BR.i18n.json +++ b/packages/i18n/src/locales/pt-BR.i18n.json @@ -5214,7 +5214,7 @@ "UI_Use_Real_Name": "Usar o nome verdadeiro", "URL": "URL", "URLs": "URLs", - "URL_is_required": "", + "URL_is_required": "URL é obrigatório", "URL_must_start_with_'http://'_or_'https://'": "A URL deve começar com 'http://' ou 'https://'", "UTC_Timezone": "Fuso horário UTC", "UTF8_Channel_Names_Validation": "Validação de nomes de canal UTF8",