You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/08/12 11:11:41 UTC

[GitHub] [superset] kgabryje opened a new pull request #16230: fix(explore): conditional formatting value validators

kgabryje opened a new pull request #16230:
URL: https://github.com/apache/superset/pull/16230


   ### SUMMARY
   This PR casts  number-like strings to numbers in order to ensure correct value validation in conditional formatting.
   Before, we were comparing values that were actually strings and not numbers, which caused incorrect validation errors.
   
   I also did some refactoring to avoid unnecessary rerenders.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Before: see linked issue
   After:
   https://user-images.githubusercontent.com/15073128/129187281-ab83bcde-870c-4715-a733-9448bdbd9c84.mov
   
   ### TESTING INSTRUCTIONS
   1. Open Table or Pivot Table v2 chart
   2. Add conditional formatter with "Between" operator and type left and right values. Verify that errors show up only if left value is larger than right. Try typing left value which is alphabetically "larger", but arithmetically smaller than right value in order to recreate the reported issue.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: fixes #16169 
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   CC @vnnw @junlincc @jinghua-qa


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] rosemarie-chiu commented on pull request #16230: fix(explore): conditional formatting value validators

Posted by GitBox <gi...@apache.org>.
rosemarie-chiu commented on pull request #16230:
URL: https://github.com/apache/superset/pull/16230#issuecomment-898551605


   🏷 2021.31


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje commented on a change in pull request #16230: fix(explore): conditional formatting value validators

Posted by GitBox <gi...@apache.org>.
kgabryje commented on a change in pull request #16230:
URL: https://github.com/apache/superset/pull/16230#discussion_r687646643



##########
File path: superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx
##########
@@ -57,6 +57,131 @@ const operatorOptions = [
   { value: COMPARATOR.BETWEEN_OR_RIGHT_EQUAL, label: '< x ≤' },
 ];
 
+const targetValueLeftValidator = (rightValue?: number) => (
+  _: any,
+  value?: number,
+) => {
+  if (!value || !rightValue || Number(rightValue) > Number(value)) {
+    return Promise.resolve();
+  }
+  return Promise.reject(
+    new Error(t('This value should be smaller than the right target value')),
+  );
+};
+
+const targetValueRightValidator = (leftValue?: number) => (

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a change in pull request #16230: fix(explore): conditional formatting value validators

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #16230:
URL: https://github.com/apache/superset/pull/16230#discussion_r687631236



##########
File path: superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx
##########
@@ -57,6 +57,131 @@ const operatorOptions = [
   { value: COMPARATOR.BETWEEN_OR_RIGHT_EQUAL, label: '< x ≤' },
 ];
 
+const targetValueLeftValidator = (rightValue?: number) => (
+  _: any,
+  value?: number,
+) => {
+  if (!value || !rightValue || Number(rightValue) > Number(value)) {
+    return Promise.resolve();
+  }
+  return Promise.reject(
+    new Error(t('This value should be smaller than the right target value')),
+  );
+};
+
+const targetValueRightValidator = (leftValue?: number) => (

Review comment:
       I might be swatting a fly with a sledge hammer, but it could be nice to have a `targetValueValidator` that encapsulates the repeated logic here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] kgabryje merged pull request #16230: fix(explore): conditional formatting value validators

Posted by GitBox <gi...@apache.org>.
kgabryje merged pull request #16230:
URL: https://github.com/apache/superset/pull/16230


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org