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/06/15 09:06:55 UTC

[GitHub] [superset] MatanBobi opened a new pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

MatanBobi opened a new pull request #15147:
URL: https://github.com/apache/superset/pull/15147


   ### SUMMARY
   The code before was creating a side effect within the render phase which isn't recommended.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   No changes.
   
   ### TESTING INSTRUCTIONS
   1. Open the native date filter.
   2. Choose previous option.
   3. Change the radio buttons to see that the values are changed.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   ~~- [ ] 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~~
   


-- 
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.

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] simcha90 commented on a change in pull request #15147: refactor: remove side effect in render from calednarframe

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



##########
File path: superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx
##########
@@ -29,12 +29,15 @@ import {
   FrameComponentProps,
 } from '../types';
 
-export function CalendarFrame(props: FrameComponentProps) {
-  let calendarRange = PreviousCalendarWeek;
-  if (CALENDAR_RANGE_SET.has(props.value as CalendarRangeType)) {
-    calendarRange = props.value;
-  } else {
-    props.onChange(calendarRange);
+export function CalendarFrame({ onChange, value }: FrameComponentProps) {
+  useEffect(() => {
+    if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+      onChange(PreviousCalendarWeek);
+    }
+  }, [onChange, value]);
+
+  if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+    return null;

Review comment:
       This functionality looks new, why added it?




-- 
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.

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] simcha90 closed pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

Posted by GitBox <gi...@apache.org>.
simcha90 closed pull request #15147:
URL: https://github.com/apache/superset/pull/15147


   


-- 
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.

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] codecov[bot] commented on pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on pull request #15147:
URL: https://github.com/apache/superset/pull/15147#issuecomment-861341795


   # [Codecov](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#15147](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9a79a4e) into [master](https://codecov.io/gh/apache/superset/commit/57035c1b93331b925e9bf91f757f365807ca70ab?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (57035c1) will **decrease** coverage by `0.07%`.
   > The diff coverage is `25.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/15147/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #15147      +/-   ##
   ==========================================
   - Coverage   77.49%   77.41%   -0.08%     
   ==========================================
     Files         969      969              
     Lines       49905    49989      +84     
     Branches     6386     6425      +39     
   ==========================================
   + Hits        38672    38700      +28     
   - Misses      11030    11086      +56     
     Partials      203      203              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `72.23% <25.00%> (-0.14%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ols/DateFilterControl/components/CalendarFrame.tsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EYXRlRmlsdGVyQ29udHJvbC9jb21wb25lbnRzL0NhbGVuZGFyRnJhbWUudHN4) | `42.85% <25.00%> (-3.30%)` | :arrow_down: |
   | [...nd/src/dashboard/components/nativeFilters/utils.ts](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvdXRpbHMudHM=) | `56.25% <0.00%> (-30.00%)` | :arrow_down: |
   | [...components/DashboardBuilder/DashboardContainer.tsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0Rhc2hib2FyZEJ1aWxkZXIvRGFzaGJvYXJkQ29udGFpbmVyLnRzeA==) | `82.97% <0.00%> (-17.03%)` | :arrow_down: |
   | [...et-frontend/src/dashboard/actions/nativeFilters.ts](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL25hdGl2ZUZpbHRlcnMudHM=) | `50.84% <0.00%> (-8.77%)` | :arrow_down: |
   | [superset-frontend/src/CRUD/CollectionTable.tsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL0NSVUQvQ29sbGVjdGlvblRhYmxlLnRzeA==) | `78.91% <0.00%> (-6.93%)` | :arrow_down: |
   | [superset-frontend/src/common/components/index.tsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbW1vbi9jb21wb25lbnRzL2luZGV4LnRzeA==) | `98.03% <0.00%> (-1.97%)` | :arrow_down: |
   | [...perset-frontend/src/dashboard/containers/Chart.jsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb250YWluZXJzL0NoYXJ0LmpzeA==) | `100.00% <0.00%> (ø)` | |
   | [...erset-frontend/src/datasource/DatasourceEditor.jsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2RhdGFzb3VyY2UvRGF0YXNvdXJjZUVkaXRvci5qc3g=) | `74.39% <0.00%> (ø)` | |
   | [...end/src/dashboard/components/SliceHeader/index.tsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL1NsaWNlSGVhZGVyL2luZGV4LnRzeA==) | `92.00% <0.00%> (ø)` | |
   | [...ard/components/FiltersBadge/DetailsPanel/index.tsx](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0ZpbHRlcnNCYWRnZS9EZXRhaWxzUGFuZWwvaW5kZXgudHN4) | `86.20% <0.00%> (ø)` | |
   | ... and [5 more](https://codecov.io/gh/apache/superset/pull/15147/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [57035c1...9a79a4e](https://codecov.io/gh/apache/superset/pull/15147?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

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] simcha90 merged pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

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


   


-- 
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.

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] MatanBobi commented on a change in pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

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



##########
File path: superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx
##########
@@ -29,12 +29,15 @@ import {
   FrameComponentProps,
 } from '../types';
 
-export function CalendarFrame(props: FrameComponentProps) {
-  let calendarRange = PreviousCalendarWeek;
-  if (CALENDAR_RANGE_SET.has(props.value as CalendarRangeType)) {
-    calendarRange = props.value;
-  } else {
-    props.onChange(calendarRange);
+export function CalendarFrame({ onChange, value }: FrameComponentProps) {
+  useEffect(() => {
+    if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+      onChange(PreviousCalendarWeek);
+    }
+  }, [onChange, value]);
+
+  if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+    return null;

Review comment:
       The whole purpose of this PR is to change the "default value" approach because it was broken.
   What I'm doing here is if the initial value isn't one of the calendar range options, I'm returning `null` so in the next render I'll get the correct value and render the proper item.




-- 
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.

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] MatanBobi commented on a change in pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

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



##########
File path: superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx
##########
@@ -29,12 +29,15 @@ import {
   FrameComponentProps,
 } from '../types';
 
-export function CalendarFrame(props: FrameComponentProps) {
-  let calendarRange = PreviousCalendarWeek;
-  if (CALENDAR_RANGE_SET.has(props.value as CalendarRangeType)) {
-    calendarRange = props.value;
-  } else {
-    props.onChange(calendarRange);
+export function CalendarFrame({ onChange, value }: FrameComponentProps) {
+  useEffect(() => {
+    if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+      onChange(PreviousCalendarWeek);
+    }
+  }, [onChange, value]);
+
+  if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+    return null;

Review comment:
       The whole purpose of this PR is to change the "default value" approach because it was broken.
   What I'm doing here is if the initial value isn't one of the calendar range options, I'm returning `null` so in the next render I'll get the correct value and render the proper select item by the value.




-- 
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.

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] MatanBobi commented on a change in pull request #15147: refactor(explore): remove side effect in render from CalendarFrame for DatePicker

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



##########
File path: superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx
##########
@@ -29,12 +29,15 @@ import {
   FrameComponentProps,
 } from '../types';
 
-export function CalendarFrame(props: FrameComponentProps) {
-  let calendarRange = PreviousCalendarWeek;
-  if (CALENDAR_RANGE_SET.has(props.value as CalendarRangeType)) {
-    calendarRange = props.value;
-  } else {
-    props.onChange(calendarRange);
+export function CalendarFrame({ onChange, value }: FrameComponentProps) {
+  useEffect(() => {
+    if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+      onChange(PreviousCalendarWeek);
+    }
+  }, [onChange, value]);
+
+  if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+    return null;

Review comment:
       The whole purpose of this PR is to change the "default value" approach because it was broken.
   What I'm doing here is if the initial value isn't one of the calendar range options, I'm returning `null` so in the next render I'll get the correct value.




-- 
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.

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