From 35be572b1676152b1e4877e68eea512a01ea4202 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Fri, 25 Sep 2020 12:05:25 +0530 Subject: [PATCH 1/4] Fix issue where unknown functions in data tree cause evaluation issues (#722) Solved by removing functions before setting the evaluatedValues map of a widget --- app/client/src/utils/DynamicBindingUtils.ts | 30 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/app/client/src/utils/DynamicBindingUtils.ts b/app/client/src/utils/DynamicBindingUtils.ts index 62f3505da7..417a325e84 100644 --- a/app/client/src/utils/DynamicBindingUtils.ts +++ b/app/client/src/utils/DynamicBindingUtils.ts @@ -240,10 +240,17 @@ export const getValidatedTree = (tree: any) => { ); parsedEntity[property] = parsed; if (!hasEvaluatedValue) { - const evaluatedValue = _.isUndefined(transformed) + const evaluatedValue = isValid + ? parsed + : _.isUndefined(transformed) ? value : transformed; - _.set(parsedEntity, `evaluatedValues.${property}`, evaluatedValue); + const safeEvaluatedValue = removeFunctions(evaluatedValue); + _.set( + parsedEntity, + `evaluatedValues.${property}`, + safeEvaluatedValue, + ); } const hasValidation = _.has(parsedEntity, `invalidProps.${property}`); @@ -621,10 +628,13 @@ function validateAndParseWidgetProperty( widget, currentTree, ); - const evaluatedValue = _.isUndefined(transformed) + const evaluatedValue = isValid + ? parsed + : _.isUndefined(transformed) ? evalPropertyValue : transformed; - _.set(widget, `evaluatedValues.${propertyName}`, evaluatedValue); + const safeEvaluatedValue = removeFunctions(evaluatedValue); + _.set(widget, `evaluatedValues.${propertyName}`, safeEvaluatedValue); if (!isValid) { _.set(widget, `invalidProps.${propertyName}`, true); _.set(widget, `validationMessages.${propertyName}`, message); @@ -757,6 +767,18 @@ const overwriteDefaultDependentProps = ( return propertyValue; }; +// We need to remove functions from data tree to avoid any unexpected identifier while JSON parsing +// Check issue https://github.com/appsmithorg/appsmith/issues/719 +const removeFunctions = (value: any) => { + if (_.isFunction(value)) { + return "Function call"; + } else if (_.isObject(value) && _.some(value, _.isFunction)) { + return JSON.parse(JSON.stringify(value)); + } else { + return value; + } +}; + /* Need to evaluated values From 170c07136b484f3aaf222e12e23c1ec6bdc6c344 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Thu, 1 Oct 2020 13:52:49 +0530 Subject: [PATCH 2/4] Adding the docker login step in client.yml for pulling the EE server docker image --- .github/workflows/client.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index c9450b4118..f9adb48467 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -131,7 +131,8 @@ jobs: - name: Pull server docker container and start it locally shell: bash run: | - docker run -d --net=host --name appsmith-internal-server -p 8080:8080 \ + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker run -d --net=host --name appsmith-internal-server-ee:release -p 8080:8080 \ --env APPSMITH_MONGODB_URI=mongodb://localhost:27017/appsmith \ --env APPSMITH_REDIS_URL=redis://localhost:6379 \ --env APPSMITH_ENCRYPTION_PASSWORD=password \ From 7614ff922ce64e11ceda3303cd496aeac0eb5b02 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Thu, 1 Oct 2020 14:06:29 +0530 Subject: [PATCH 3/4] Correcting the image name in client.yml build file --- .github/workflows/client.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index f9adb48467..7d59826b61 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -132,13 +132,13 @@ jobs: shell: bash run: | echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin - docker run -d --net=host --name appsmith-internal-server-ee:release -p 8080:8080 \ + docker run -d --net=host --name appsmith-internal-server -p 8080:8080 \ --env APPSMITH_MONGODB_URI=mongodb://localhost:27017/appsmith \ --env APPSMITH_REDIS_URL=redis://localhost:6379 \ --env APPSMITH_ENCRYPTION_PASSWORD=password \ --env APPSMITH_ENCRYPTION_SALT=salt \ --env APPSMITH_IS_SELF_HOSTED=false \ - appsmith/appsmith-server:release + appsmith/appsmith-server-ee:release - name: Installing Yarn serve run: | From 5fd163e3f42b269518a6f1d6549cc3e680be8f1a Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Fri, 9 Oct 2020 13:09:10 +0530 Subject: [PATCH 4/4] Moving the Github Action for client to pull_request_target --- .github/workflows/client.yml | 2 +- app/client/README.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 011acc27ef..23d05f0625 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -6,7 +6,7 @@ on: # Only trigger if files have changed in this specific path paths: - 'app/client/**' - pull_request_target: + pull_request: branches: [ release, master ] paths: - 'app/client/**' diff --git a/app/client/README.md b/app/client/README.md index 2cb736750f..2e62fd2d81 100755 --- a/app/client/README.md +++ b/app/client/README.md @@ -8,3 +8,5 @@ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). For details on setting up your development machine, please refer to the [Setup Guide](https://github.com/appsmithorg/appsmith/blob/release/contributions/ClientSetup.md) + +