appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

feat: Add validation dependency

Open rishabhrathod01 opened this issue 3 years ago • 26 comments

Problem

Why do we need validation dependency?

  • When on change of particular property value if other property needs revalidation then current evaluation architecture do not support such validation run.

Issues to resolve

Fixes #15303 Fixes #17159 Fixes https://github.com/appsmithorg/appsmith/issues/16170

Solution

New Validation Flow

validate a property after its evaluation and check if there are other properties that need to revalidate on a change of this value.

  • if yes run validation for those properties.

How does validation dependency get created?

  • every widget’s property will keep static dependencies array in validation property like shown below.
{
	validation: {
    type: ValidationTypes.FUNCTION,
    params: {
      fn: defaultOptionValueValidation,
      expected: {
        type: 'value1 or { "label": "label1", "value": "value1" }',
        example: `value1 | { "label": "label1", "value": "value1" }`,
        autocompleteDataType: AutocompleteDataType.STRING,
      },
      dependentPaths: ["serverSideFiltering", "options"],
    },
    dependencies: ["serverSideFiltering", "options"],
  }
}

This dependentPaths array will be used to form validationDependencyMap.

Changes

  • The code editor component wasn't re-rendering for a few cases. Due to this updates were not shown until the component state was changed.

  • In CreateFirstTree, After evaluateTree we run validateTree. In validateTree, we validate all the properties in validationPaths. Here, if the errors were resolved on revalidation, it didn't reset the validation errors stored in data tree before. Now, this PR adds the reset logic.

  • Created validationDependencyMap to re-validate properties on change of the property their validation depends upon.

  • After each property evaluates in updateDataTree, we check if re-validation is needed, if yes then we re-validate dependent properties.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • jest test

Checklist:

  • [x] My code follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes

rishabhrathod01 avatar Sep 28 '22 09:09 rishabhrathod01

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
appsmith ✅ Ready (Inspect) Visit Preview Oct 18, 2022 at 6:39AM (UTC)

vercel[bot] avatar Sep 28 '22 09:09 vercel[bot]

Unable to find test scripts. Please add necessary tests to the PR.

github-actions[bot] avatar Sep 28 '22 09:09 github-actions[bot]

Unable to find test scripts. Please add necessary tests to the PR.

github-actions[bot] avatar Sep 28 '22 10:09 github-actions[bot]

/ok-to-test sha=538bc11

rishabhrathod01 avatar Oct 07 '22 11:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3204308079. Workflow: Appsmith External Integration Test Workflow. Commit: 538bc11. PR: 17138.

github-actions[bot] avatar Oct 07 '22 11:10 github-actions[bot]

/ok-to-test sha=891630b

rishabhrathod01 avatar Oct 08 '22 08:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3209692840. Workflow: Appsmith External Integration Test Workflow. Commit: 891630b. PR: 17138.

github-actions[bot] avatar Oct 08 '22 08:10 github-actions[bot]

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/3209692840. Commit: ``. Results:

Click to view performance test results

Run 1 (ms) Run 2 (ms) Run 3 (ms) Run 4 (ms) Run 5 (ms) Minimum (ms) Median (ms) Mean (ms) Range (%) SD.Sample (%) SD.Population (%)
SELECT_CATEGORY
scripting 330.94 373.71 373.33 363.97 328.64 328.64 363.97 354.12 12.73 6.37 5.70
painting 7.25 7.88 4.34 4.04 3.64 3.64 4.34 5.43 78.08 36.46 32.60
rendering 105.02 105.58 107.71 108.68 104.62 104.62 105.58 106.32 3.82 1.67 1.50
BIND_TABLE_DATA
scripting 1068.31 1002.8 1063.05 1037.26 1006.01 1002.8 1037.26 1035.49 6.33 2.97 2.65
painting 12.94 22.56 15.08 15.56 9.11 9.11 15.08 15.05 89.37 32.62 29.17
rendering 813.9 824.77 801.46 811.39 776.81 776.81 811.39 805.67 5.95 2.25 2.01
CLICK_ON_TABLE_ROW
scripting 855.74 913.7 881.83 889.58 885.97 855.74 885.97 885.36 6.55 2.34 2.09
painting 9.42 9.68 15.64 8.18 8.73 8.18 9.42 10.33 72.22 29.33 26.23
rendering 298.39 309.85 296.02 301.16 303.9 296.02 301.16 301.86 4.58 1.77 1.59
UPDATE_POST_TITLE
scripting 923.29 897.36 826.25 841.55 912.81 826.25 897.36 880.25 11.02 4.96 4.44
painting 7.81 8.25 14.93 8.86 15.07 7.81 8.86 10.98 66.12 33.61 30.05
rendering 584.8 589.54 577.33 604.54 591.5 577.33 589.54 589.54 4.62 1.70 1.52
OPEN_MODAL
scripting 431.85 460.15 447.84 484.13 494.77 431.85 460.15 463.75 13.57 5.56 4.97
painting 15.62 14.46 19.8 13.19 10.99 10.99 14.46 14.81 59.49 22.08 19.78
rendering 1179.42 1199.31 1167.56 1289.56 1192.98 1167.56 1192.98 1205.77 10.12 4.02 3.59
CLOSE_MODAL
scripting 206.76 223.7 227.59 223.31 250.83 206.76 223.7 226.44 19.46 6.99 6.25
painting 10.91 4.63 8.4 16.35 9.35 4.63 9.35 9.93 118.03 43.00 38.47
rendering 894.09 909.22 877.35 892.48 872.15 872.15 892.48 889.06 4.17 1.66 1.48
SELECT_WIDGET_MENU_OPEN
scripting 273.22 271.28 291.75 277.41 284.58 271.28 277.41 279.65 7.32 3.03 2.71
painting 5.96 9.58 9.49 9.75 13.93 5.96 9.58 9.74 81.83 29.06 25.98
rendering 636.64 635.1 644.22 644.36 645.37 635.1 644.22 641.14 1.60 0.76 0.68
SELECT_WIDGET_SELECT_OPTION
scripting 161.24 144.9 162.2 166.39 159.43 144.9 161.24 158.83 13.53 5.16 4.61
painting 2.47 3.39 12.64 6.32 4.51 2.47 4.51 5.87 173.25 68.99 61.67
rendering 305.98 302.95 307.98 319.1 319.01 302.95 307.98 311 5.19 2.43 2.18

github-actions[bot] avatar Oct 08 '22 08:10 github-actions[bot]

/ok-to-test sha=cd76d1d

rishabhrathod01 avatar Oct 10 '22 05:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3217345928. Workflow: Appsmith External Integration Test Workflow. Commit: cd76d1d. PR: 17138.

github-actions[bot] avatar Oct 10 '22 06:10 github-actions[bot]

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/3217345928. Commit: ``. Results:

Click to view performance test results

Run 1 (ms) Run 2 (ms) Run 3 (ms) Run 4 (ms) Run 5 (ms) Minimum (ms) Median (ms) Mean (ms) Range (%) SD.Sample (%) SD.Population (%)
SELECT_CATEGORY
scripting 337.6 404.39 347.23 349.92 361.24 337.6 349.92 360.08 18.55 7.27 6.50
painting 6 4.76 5.62 3.26 3.33 3.26 4.76 4.59 59.69 27.67 24.62
rendering 107.63 114.82 107.1 106.31 107.57 106.31 107.57 108.69 7.83 3.19 2.85
BIND_TABLE_DATA
scripting 1099.86 1222.22 1100.46 1103.08 1038.07 1038.07 1100.46 1112.74 16.55 6.02 5.39
painting 19.36 31.35 16.76 18.96 18.01 16.76 18.96 20.89 69.84 28.39 25.42
rendering 826.52 974.06 805.17 802.2 772.81 772.81 805.17 836.15 24.07 9.50 8.50
CLICK_ON_TABLE_ROW
scripting 817.96 1038.08 887.26 955.63 900.98 817.96 900.98 919.98 23.93 8.94 8.00
painting 11.93 18.65 8.51 10.17 8.09 8.09 10.17 11.47 92.07 37.40 33.48
rendering 314.61 351.09 295.53 304.19 315.75 295.53 314.61 316.23 17.57 6.69 5.99
UPDATE_POST_TITLE
scripting 973.5 1121.62 904.89 918.58 865.33 865.33 918.58 956.78 26.79 10.45 9.34
painting 9.63 17.44 10.23 9.36 8.41 8.41 9.63 11.01 82.02 33.15 29.70
rendering 608.3 666.15 605.22 579.64 602.61 579.64 605.22 612.38 14.13 5.25 4.69
OPEN_MODAL
scripting 471.95 615.89 453.1 440.88 452.25 440.88 453.1 486.81 35.95 15.00 13.41
painting 9.36 13.6 12.54 9.37 11.8 9.36 11.8 11.33 37.42 16.86 15.09
rendering 1314.31 1366.81 1189.86 1174.18 1168.18 1168.18 1189.86 1242.67 15.98 7.37 6.59
CLOSE_MODAL
scripting 201.62 302.62 232.14 239.03 212.62 201.62 232.14 237.61 42.51 16.54 14.79
painting 6.08 6.49 5.1 4.54 4.57 4.54 5.1 5.36 36.38 16.60 14.74
rendering 918.15 984.07 913.19 901.05 890.15 890.15 913.19 921.32 10.19 3.99 3.57
SELECT_WIDGET_MENU_OPEN
scripting 312.81 278.61 277.02 307.76 308.82 277.02 307.76 297 12.05 5.94 5.31
painting 8.26 5.81 5.67 7.86 9.99 5.67 7.86 7.52 57.45 24.07 21.54
rendering 715.58 654.36 628.81 690.35 647.48 628.81 654.36 667.32 13.00 5.25 4.69
SELECT_WIDGET_SELECT_OPTION
scripting 192.39 158.15 161.11 155.77 166.53 155.77 161.11 166.79 21.96 8.91 7.97
painting 3.77 4.92 4.08 2.7 3.41 2.7 3.77 3.78 58.73 21.69 19.31
rendering 341.25 325.42 312.73 322.5 318.17 312.73 322.5 324.01 8.80 3.32 2.97

github-actions[bot] avatar Oct 10 '22 07:10 github-actions[bot]

/ok-to-test sha=441d51c

rishabhrathod01 avatar Oct 11 '22 07:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3224947051. Workflow: Appsmith External Integration Test Workflow. Commit: 441d51c. PR: 17138.

github-actions[bot] avatar Oct 11 '22 07:10 github-actions[bot]

/ok-to-test sha=b8de5c1

rishabhrathod01 avatar Oct 16 '22 13:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3259562462. Workflow: Appsmith External Integration Test Workflow. Commit: b8de5c1. PR: 17138. Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=17138&runId=3259562462_1

github-actions[bot] avatar Oct 16 '22 13:10 github-actions[bot]

/ok-to-test sha=b8de5c1

rishabhrathod01 avatar Oct 16 '22 13:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3259581866. Workflow: Appsmith External Integration Test Workflow. Commit: b8de5c1. PR: 17138. Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=17138&runId=3259581866_1

github-actions[bot] avatar Oct 16 '22 13:10 github-actions[bot]

/ok-to-test sha=07efb6f

rishabhrathod01 avatar Oct 17 '22 01:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3261731582. Workflow: Appsmith External Integration Test Workflow. Commit: 07efb6f. PR: 17138. Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=17138&runId=3261731582_1

github-actions[bot] avatar Oct 17 '22 01:10 github-actions[bot]

/ok-to-test sha=de2dc07

rishabhrathod01 avatar Oct 17 '22 07:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3263386231. Workflow: Appsmith External Integration Test Workflow. Commit: de2dc07. PR: 17138. Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=17138&runId=3263386231_1

github-actions[bot] avatar Oct 17 '22 08:10 github-actions[bot]

Deployment failed with the following error:

Resource is limited - try again in 5 hours (more than 100, code: "api-deployments-free-per-day").

vercel[bot] avatar Oct 17 '22 20:10 vercel[bot]

/ok-to-test sha=a375236

rishabhrathod01 avatar Oct 18 '22 03:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3270536567. Workflow: Appsmith External Integration Test Workflow. Commit: a375236. PR: 17138. Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=17138&runId=3270536567_1

github-actions[bot] avatar Oct 18 '22 04:10 github-actions[bot]

/ok-to-test sha=d07abd0

rishabhrathod01 avatar Oct 18 '22 06:10 rishabhrathod01

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3271269663. Workflow: Appsmith External Integration Test Workflow. Commit: d07abd0. PR: 17138. Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=17138&runId=3271269663_1

github-actions[bot] avatar Oct 18 '22 07:10 github-actions[bot]