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/19 19:14:54 UTC

[GitHub] [superset] ktmud opened a new pull request #16362: feat(explore): improve typing for Dnd controls and add logging

ktmud opened a new pull request #16362:
URL: https://github.com/apache/superset/pull/16362


   ### SUMMARY
   
   Improve typing for Explore Dnd controls and add logging for its usage. 
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] 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.

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] ktmud commented on a change in pull request #16362: refactor(explore): improve typing for Dnd controls

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



##########
File path: superset-frontend/src/explore/components/Control.tsx
##########
@@ -18,6 +18,7 @@
  */
 import React, { ReactNode, useCallback, useState } from 'react';
 import { ControlType } from '@superset-ui/chart-controls';
+import { ControlComponentProps as BaseControlComponentProps } from '@superset-ui/chart-controls/lib/shared-controls/components/types';

Review comment:
       Agreed. I'll do that the next time I touch superset-ui.




-- 
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 #16362: feat(explore): improve typing for Dnd controls and add logging

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



##########
File path: superset-frontend/src/explore/components/DatasourcePanel/index.tsx
##########
@@ -193,61 +194,64 @@ export default function DataSourcePanel({
   const DEFAULT_MAX_COLUMNS_LENGTH = 50;
   const DEFAULT_MAX_METRICS_LENGTH = 50;
 
-  const search = useCallback(
-    debounce((value: string) => {
-      if (value === '') {
-        setList({ columns, metrics });
-        return;
-      }
-      setList({
-        columns: matchSorter(columns, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'column_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-        }),
-        metrics: matchSorter(metrics, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'metric_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-          baseSort: (a, b) =>
-            Number(b.item.is_certified) - Number(a.item.is_certified) ||
-            String(a.rankedValue).localeCompare(b.rankedValue),
-        }),
-      });
-    }, FAST_DEBOUNCE),
-    [columns, metrics],
+  const search = debounce(

Review comment:
       I've just verified - simply replacing useCallback with useMemo solves the eslint problem
   ```
   const search = useMemo(
       () =>
         debounce((value: string) => {
   ...
   ```




-- 
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] ktmud commented on pull request #16362: feat(explore): improve typing for Dnd controls and add logging

Posted by GitBox <gi...@apache.org>.
ktmud commented on pull request #16362:
URL: https://github.com/apache/superset/pull/16362#issuecomment-902179092


   [HOLD] the DnD Metrics control has a bug where adding a new metric will wipe out existing metrics. The typing for the MetricControl is suboptimal, which is probably why the bug exists in the first place...
   
   @kgabryje I'll try to fix this in a separate PR unless you are already on 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.

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 #16362: refactor(explore): improve typing for Dnd controls

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



##########
File path: superset-frontend/src/explore/components/Control.tsx
##########
@@ -18,6 +18,7 @@
  */
 import React, { ReactNode, useCallback, useState } from 'react';
 import { ControlType } from '@superset-ui/chart-controls';
+import { ControlComponentProps as BaseControlComponentProps } from '@superset-ui/chart-controls/lib/shared-controls/components/types';

Review comment:
       Non-blocking - should we export that from `chart-controls` in the next release of superset-ui, so that we can import from `'@superset-ui/chart-controls'`?




-- 
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] ktmud commented on pull request #16362: refactor(explore): improve typing for Dnd controls

Posted by GitBox <gi...@apache.org>.
ktmud commented on pull request #16362:
URL: https://github.com/apache/superset/pull/16362#issuecomment-902860261


   @kgabryje do you mind taking another look? 


-- 
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] ktmud commented on a change in pull request #16362: refactor(explore): improve typing for Dnd controls

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



##########
File path: superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.tsx
##########
@@ -176,7 +186,9 @@ export const DndMetricSelect = (props: any) => {
 
   const onNewMetric = useCallback(
     (newMetric: Metric) => {
-      const newValue = props.multi ? [...value, newMetric] : [newMetric];
+      const newValue = props.multi
+        ? [...value, newMetric.metric_name]
+        : [newMetric.metric_name];

Review comment:
       Got it. Thanks for the testing and pointing this out!




-- 
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] codecov[bot] commented on pull request #16362: refactor(explore): improve typing for Dnd controls

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


   # [Codecov](https://codecov.io/gh/apache/superset/pull/16362?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 [#16362](https://codecov.io/gh/apache/superset/pull/16362?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7c45fb3) into [master](https://codecov.io/gh/apache/superset/commit/518c3c9ae088f780f1874c63eab416ee1cbb4a61?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (518c3c9) will **increase** coverage by `0.01%`.
   > The diff coverage is `68.00%`.
   
   > :exclamation: Current head 7c45fb3 differs from pull request most recent head 6e8ff55. Consider uploading reports for the commit 6e8ff55 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/16362/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/16362?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   #16362      +/-   ##
   ==========================================
   + Coverage   76.64%   76.66%   +0.01%     
   ==========================================
     Files        1000     1000              
     Lines       53486    53488       +2     
     Branches     6815     6816       +1     
   ==========================================
   + Hits        40995    41004       +9     
   + Misses      12255    12248       -7     
     Partials      236      236              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `70.91% <68.00%> (+0.02%)` | :arrow_up: |
   
   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/16362?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...perset-frontend/src/explore/components/Control.tsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9Db250cm9sLnRzeA==) | `76.47% <ø> (ø)` | |
   | [...-frontend/src/explore/components/ControlHeader.jsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9Db250cm9sSGVhZGVyLmpzeA==) | `86.20% <ø> (ø)` | |
   | [superset-frontend/src/views/CRUD/types.ts](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3ZpZXdzL0NSVUQvdHlwZXMudHM=) | `100.00% <ø> (ø)` | |
   | [...ontrols/DndColumnSelectControl/DndMetricSelect.tsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZE1ldHJpY1NlbGVjdC50c3g=) | `40.88% <20.00%> (-0.53%)` | :arrow_down: |
   | [...d/src/explore/components/DatasourcePanel/index.tsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9EYXRhc291cmNlUGFuZWwvaW5kZXgudHN4) | `73.95% <69.23%> (ø)` | |
   | [...ontrols/DndColumnSelectControl/DndColumnSelect.tsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZENvbHVtblNlbGVjdC50c3g=) | `47.56% <100.00%> (ø)` | |
   | [...ontrols/DndColumnSelectControl/DndFilterSelect.tsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZEZpbHRlclNlbGVjdC50c3g=) | `51.33% <100.00%> (+6.00%)` | :arrow_up: |
   | [...controls/DndColumnSelectControl/DndSelectLabel.tsx](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZFNlbGVjdExhYmVsLnRzeA==) | `77.27% <100.00%> (ø)` | |
   | [...ols/DndColumnSelectControl/utils/optionSelector.ts](https://codecov.io/gh/apache/superset/pull/16362/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL3V0aWxzL29wdGlvblNlbGVjdG9yLnRz) | `46.15% <100.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/16362?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/16362?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 [518c3c9...6e8ff55](https://codecov.io/gh/apache/superset/pull/16362?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.

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 pull request #16362: feat(explore): improve typing for Dnd controls and add logging

Posted by GitBox <gi...@apache.org>.
kgabryje commented on pull request #16362:
URL: https://github.com/apache/superset/pull/16362#issuecomment-902681016


   > [HOLD] The UX for overriding single select MetricControl is quite confusing. While Drag & Drop, There is no clear indication that a control will only accept one metric.
   
   We indicate that a control accepts only 1 value by not displaying ghost button when a value is added. However, I do agree that we don't communicate clearly that dropping another value will replace the first one...


-- 
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] ktmud merged pull request #16362: refactor(explore): improve typing for Dnd controls

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


   


-- 
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 #16362: feat(explore): improve typing for Dnd controls and add logging

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



##########
File path: superset-frontend/src/explore/components/DatasourcePanel/index.tsx
##########
@@ -193,61 +194,64 @@ export default function DataSourcePanel({
   const DEFAULT_MAX_COLUMNS_LENGTH = 50;
   const DEFAULT_MAX_METRICS_LENGTH = 50;
 
-  const search = useCallback(
-    debounce((value: string) => {
-      if (value === '') {
-        setList({ columns, metrics });
-        return;
-      }
-      setList({
-        columns: matchSorter(columns, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'column_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-        }),
-        metrics: matchSorter(metrics, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'metric_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-          baseSort: (a, b) =>
-            Number(b.item.is_certified) - Number(a.item.is_certified) ||
-            String(a.rankedValue).localeCompare(b.rankedValue),
-        }),
-      });
-    }, FAST_DEBOUNCE),
-    [columns, metrics],
+  const search = debounce(

Review comment:
       Is there a reason why you changed the order here? According to https://dmitripavlutin.com/react-throttle-debounce/ `useCallback` should go first (although it seems that what we had here wasn't fully correct as we should wrap debounce function in useMemo...)




-- 
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] ktmud commented on a change in pull request #16362: feat(explore): improve typing for Dnd controls and add logging

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



##########
File path: superset-frontend/src/explore/components/DatasourcePanel/index.tsx
##########
@@ -193,61 +194,64 @@ export default function DataSourcePanel({
   const DEFAULT_MAX_COLUMNS_LENGTH = 50;
   const DEFAULT_MAX_METRICS_LENGTH = 50;
 
-  const search = useCallback(
-    debounce((value: string) => {
-      if (value === '') {
-        setList({ columns, metrics });
-        return;
-      }
-      setList({
-        columns: matchSorter(columns, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'column_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-        }),
-        metrics: matchSorter(metrics, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'metric_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-          baseSort: (a, b) =>
-            Number(b.item.is_certified) - Number(a.item.is_certified) ||
-            String(a.rankedValue).localeCompare(b.rankedValue),
-        }),
-      });
-    }, FAST_DEBOUNCE),
-    [columns, metrics],
+  const search = debounce(

Review comment:
       ESLint react-hook plugin will complain not being able to detect exhaustive deps and suggests making the callback inline.




-- 
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] junlincc commented on pull request #16362: feat(explore): improve typing for Dnd controls and add logging

Posted by GitBox <gi...@apache.org>.
junlincc commented on pull request #16362:
URL: https://github.com/apache/superset/pull/16362#issuecomment-902820819


   thanks this is awesome! @ktmud do you mind splitting this pr into 2 one for improving typing one for logging? 


-- 
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] ktmud commented on a change in pull request #16362: feat(explore): improve typing for Dnd controls and add logging

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



##########
File path: superset-frontend/src/explore/components/DatasourcePanel/index.tsx
##########
@@ -193,61 +194,64 @@ export default function DataSourcePanel({
   const DEFAULT_MAX_COLUMNS_LENGTH = 50;
   const DEFAULT_MAX_METRICS_LENGTH = 50;
 
-  const search = useCallback(
-    debounce((value: string) => {
-      if (value === '') {
-        setList({ columns, metrics });
-        return;
-      }
-      setList({
-        columns: matchSorter(columns, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'column_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-        }),
-        metrics: matchSorter(metrics, value, {
-          keys: [
-            {
-              key: 'verbose_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: 'metric_name',
-              threshold: rankings.CONTAINS,
-            },
-            {
-              key: item =>
-                [item.description, item.expression].map(
-                  x => x?.replace(/[_\n\s]+/g, ' ') || '',
-                ),
-              threshold: rankings.CONTAINS,
-              maxRanking: rankings.CONTAINS,
-            },
-          ],
-          keepDiacritics: true,
-          baseSort: (a, b) =>
-            Number(b.item.is_certified) - Number(a.item.is_certified) ||
-            String(a.rankedValue).localeCompare(b.rankedValue),
-        }),
-      });
-    }, FAST_DEBOUNCE),
-    [columns, metrics],
+  const search = debounce(

Review comment:
       Cool. That should work!




-- 
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] ktmud commented on a change in pull request #16362: refactor(explore): improve typing for Dnd controls

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



##########
File path: superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.tsx
##########
@@ -104,6 +108,12 @@ const columnsContainAllMetrics = (
   );
 };
 
+export type DndMetricSelectProps = DndControlProps<ValueType> & {
+  savedMetrics: savedMetricType[];
+  columns: ColumnMeta[];
+  datasourceType?: DatasourceType;
+};
+
 export const DndMetricSelect = (props: any) => {

Review comment:
       TODO: get rid of this `any`. Currently `DndMetricSelectProps` will conflict with too many things within this function. This file needs a bigger overhaul.




-- 
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] ktmud edited a comment on pull request #16362: feat(explore): improve typing for Dnd controls and add logging

Posted by GitBox <gi...@apache.org>.
ktmud edited a comment on pull request #16362:
URL: https://github.com/apache/superset/pull/16362#issuecomment-902179092


   [HOLD] The UX for overriding single select MetricControl is quite confusing. While Drag & Drop, There is no clear indication that a control will only accept one metric. 


-- 
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] michellethomas commented on a change in pull request #16362: refactor(explore): improve typing for Dnd controls

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



##########
File path: superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.tsx
##########
@@ -176,7 +186,9 @@ export const DndMetricSelect = (props: any) => {
 
   const onNewMetric = useCallback(
     (newMetric: Metric) => {
-      const newValue = props.multi ? [...value, newMetric] : [newMetric];
+      const newValue = props.multi
+        ? [...value, newMetric.metric_name]
+        : [newMetric.metric_name];

Review comment:
       @ktmud I believe this introduced a bug with dragging columns into the metrics section and creating a `SIMPLE` expression for the column. When you drag a column into the metrics section the data looks like the data listed below and does not have a metric_name. This leads to an undefined option being returned and later errors:
   ```
   aggregate: "COUNT_DISTINCT"
   column: {column_name: "target"}
   expressionType: "SIMPLE"
   hasCustomLabel: false
   isNew: false
   label: "COUNT_DISTINCT(target)"
   optionName: "metric_1vo4t2m2tjl_0nhrga77x9pf"
   sqlExpression: null
   ```




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