From e08d2536676701122b989e53e4cbc675681702cc Mon Sep 17 00:00:00 2001 From: harshit078 Date: Thu, 29 Aug 2024 19:06:51 +0530 Subject: [PATCH] Fix comments --- .../SettingsDevelopersApiKeyDetail.tsx | 4 ++-- .../SettingsDevelopersWebhooksNew.tsx | 22 +++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx index 1b4898f284ff..215eb3145b87 100644 --- a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx +++ b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx @@ -213,7 +213,7 @@ export const SettingsDevelopersApiKeyDetail = () => { confirmationValue="yes" isOpen={isDeleteApiKeyModalOpen} setIsOpen={setIsDeleteApiKeyModalOpen} - title="Delete Api key" + title="Delete API key" subtitle={ <> Please type "yes" to confirm you want to delete this API Key. Be @@ -228,7 +228,7 @@ export const SettingsDevelopersApiKeyDetail = () => { confirmationValue="yes" isOpen={isRegenerateKeyModalOpen} setIsOpen={setIsRegenerateKeyModalOpen} - title="Regenerate an Api key" + title="Regenerate an API key" subtitle={ <> If you’ve lost this key, you can regenerate it, but be aware that diff --git a/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx b/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx index 2af1c78c7646..13ea44848f70 100644 --- a/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx +++ b/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx @@ -29,13 +29,13 @@ export const SettingsDevelopersWebhooksNew = () => { const validateUrl = (url: string) => { const urlPattern = new RegExp( - '^(https?:\\/\\/)?' + // protocol - '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name - '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address - '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path - '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string + '^(https?:\\/\\/)?' + + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + + '((\\d{1,3}\\.){3}\\d{1,3}))' + + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + + '(\\?[;&a-z\\d%_.~+=-]*)?' + '(\\#[-a-z\\d_]*)?$', - 'i', // fragment locator + 'i', ); return !!urlPattern.test(url); }; @@ -43,11 +43,6 @@ export const SettingsDevelopersWebhooksNew = () => { const handleSave = async () => { const trimmedUrl = formValues.targetUrl.trim(); - if (!trimmedUrl) { - setIsUrlValid(false); - throw new Error('Endpoint URL cannot be empty'); - } - if (!validateUrl(trimmedUrl)) { setIsUrlValid(false); return; @@ -98,8 +93,8 @@ export const SettingsDevelopersWebhooksNew = () => { error={isUrlValid ? undefined : 'Please enter a valid URL'} onKeyDown={(e) => { if (e.key === 'Enter') { - e.preventDefault(); // Prevent form submission or other default behaviors - handleSave(); // Manually trigger the save process, which includes validation + e.preventDefault(); + handleSave(); } }} onChange={(value) => { @@ -107,7 +102,6 @@ export const SettingsDevelopersWebhooksNew = () => { ...prevState, targetUrl: value, })); - setIsUrlValid(validateUrl(value)); }} fullWidth />