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/01/22 17:00:45 UTC

[GitHub] [superset] nikolagigic commented on a change in pull request #12675: feat(explore): better search for dataset pane

nikolagigic commented on a change in pull request #12675:
URL: https://github.com/apache/superset/pull/12675#discussion_r562770952



##########
File path: superset-frontend/src/explore/components/DatasourcePanel.tsx
##########
@@ -159,36 +160,65 @@ const LabelContainer = styled.div`
   }
 `;
 
-const DataSourcePanel = ({
+export default function DataSourcePanel({
   datasource,
   controls: { datasource: datasourceControl },
   actions,
-}: Props) => {
+}: Props) {
   const { columns, metrics } = datasource;
   const [lists, setList] = useState({
     columns,
     metrics,
   });
-  const search = ({ target: { value } }: { target: { value: string } }) => {
+
+  const search = debounce((value: string) => {
     if (value === '') {
       setList({ columns, metrics });
       return;
     }
     setList({
       columns: matchSorter(columns, value, {
-        keys: ['column_name', 'expression', 'description', 'verbose_name'],
+        keys: [
+          'column_name',
+          'verbose_name',
+          {
+            key: 'description',
+            threshold: rankings.STARTS_WITH,

Review comment:
       Isn't this going to eliminate all the columns which description does not start with a search keyword and put all the columns that start with search keyword on top of the list?

##########
File path: superset-frontend/src/explore/components/DatasourcePanel.tsx
##########
@@ -159,36 +160,65 @@ const LabelContainer = styled.div`
   }
 `;
 
-const DataSourcePanel = ({
+export default function DataSourcePanel({
   datasource,
   controls: { datasource: datasourceControl },
   actions,
-}: Props) => {
+}: Props) {
   const { columns, metrics } = datasource;
   const [lists, setList] = useState({
     columns,
     metrics,
   });
-  const search = ({ target: { value } }: { target: { value: string } }) => {
+
+  const search = debounce((value: string) => {
     if (value === '') {
       setList({ columns, metrics });
       return;
     }
     setList({
       columns: matchSorter(columns, value, {
-        keys: ['column_name', 'expression', 'description', 'verbose_name'],
+        keys: [
+          'column_name',
+          'verbose_name',
+          {
+            key: 'description',
+            threshold: rankings.STARTS_WITH,
+          },
+          {
+            key: 'expression',
+            threshold: rankings.STARTS_WITH,

Review comment:
       Same 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.

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