From dca9e705a5844389b3c17807c066e362719e0450 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Mon, 17 Aug 2020 19:51:42 +0530 Subject: [PATCH 1/2] Access env variables in index.html via ejs (#334) * Fix for intercom env variable * Add GA via env variables --- app/client/public/index.html | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/client/public/index.html b/app/client/public/index.html index 373ce7f074..5c9057683b 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -16,6 +16,23 @@ transition: all ease-in 0.3s; } + + + @@ -84,13 +101,6 @@ intercomAppID: parseConfig("__APPSMITH_INTERCOM_APP_ID__"), }; - From 664d55053d1e63c179c0595c6cec69ac8cccaad2 Mon Sep 17 00:00:00 2001 From: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Date: Mon, 17 Aug 2020 19:53:57 +0530 Subject: [PATCH 2/2] Add email validation for email input (#276) Co-authored-by: Hetu Nandu --- app/client/src/widgets/InputWidget.tsx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/app/client/src/widgets/InputWidget.tsx b/app/client/src/widgets/InputWidget.tsx index 889df93c60..d2c17d7ee2 100644 --- a/app/client/src/widgets/InputWidget.tsx +++ b/app/client/src/widgets/InputWidget.tsx @@ -58,7 +58,29 @@ class InputWidget extends BaseWidget { static getDerivedPropertiesMap(): DerivedPropertiesMap { return { - isValid: `{{!!(this.isRequired ? this.text && this.text.length > 0 ? this.regex ? new RegExp(this.regex).test(this.text) : true : false : this.regex ? new RegExp(this.regex).test(this.text) : true)}}`, + isValid: `{{ + function(){ + const isEmailType = this.inputType === "EMAIL"; + if(isEmailType) { + const emailRegex = new RegExp(/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/); + return emailRegex.test(this.text); + } else if(this.isRequired) { + if(this.text && this.text.length > 0) { + if(this.regex) { + return new RegExp(this.regex).test(this.text) + } else { + return true; + } + } else { + return false; + } + } if(this.regex) { + return new RegExp(this.regex).test(this.text) + } else { + return true; + } + }() + }}`, value: `{{this.text}}`, }; } @@ -117,6 +139,7 @@ class InputWidget extends BaseWidget { const value = this.state.text || ""; const isInvalid = "isValid" in this.props && !this.props.isValid && !!this.props.isDirty; + const conditionalProps: Partial = {}; conditionalProps.errorMessage = this.props.errorMessage; if (this.props.isRequired && value.length === 0) {