diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index 208cc2a309e55..c0c8182753522 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -17182,10 +17182,27 @@ "xss": "^1.0.6" }, "dependencies": { + "@babel/runtime": { + "version": "7.12.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz", + "integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==", + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, "d3-array": { "version": "2.9.1", "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.9.1.tgz", "integrity": "sha512-Ob7RdOtkqsjx1NWyQHMFLtCSk6/aKTxDdC4ZIolX+O+mDD2RzrsYgAyc0WGAlfYFVELLSilS7w8BtE3PKM8bHg==" + }, + "match-sorter": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/match-sorter/-/match-sorter-4.2.1.tgz", + "integrity": "sha512-s+3h9TiZU9U1pWhIERHf8/f4LmBN6IXaRgo2CI17+XGByGS1GvG5VvXK9pcGyCjGe3WM3mSYRC3ipGrd5UEVgw==", + "requires": { + "@babel/runtime": "^7.10.5", + "remove-accents": "0.4.2" + } } } }, @@ -22840,7 +22857,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -26000,7 +26017,7 @@ "dependencies": { "domelementtype": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", "dev": true } @@ -36034,7 +36051,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" }, "jsonfile": { @@ -38501,7 +38518,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -44669,7 +44686,7 @@ }, "regexpu-core": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz", "integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=", "dev": true, "requires": { @@ -44680,13 +44697,13 @@ }, "regjsgen": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "resolved": "http://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", "dev": true }, "regjsparser": { "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "resolved": "http://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { @@ -47095,7 +47112,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { diff --git a/superset-frontend/package.json b/superset-frontend/package.json index 16b99f59c0ad9..2d176539f9e06 100644 --- a/superset-frontend/package.json +++ b/superset-frontend/package.json @@ -121,6 +121,7 @@ "json-stringify-pretty-compact": "^2.0.0", "lodash": "^4.17.20", "lodash-es": "^4.17.14", + "match-sorter": "^4.1.0", "mathjs": "^8.0.1", "memoize-one": "^5.1.1", "moment": "^2.26.0", diff --git a/superset-frontend/src/explore/components/DatasourcePanel.tsx b/superset-frontend/src/explore/components/DatasourcePanel.tsx index b715ecd01dd66..637c0f96df269 100644 --- a/superset-frontend/src/explore/components/DatasourcePanel.tsx +++ b/superset-frontend/src/explore/components/DatasourcePanel.tsx @@ -24,6 +24,7 @@ import { MetricOption, ControlType, } from '@superset-ui/chart-controls'; +import matchSorter from 'match-sorter'; import { ExploreActions } from '../actions/exploreActions'; import Control from './Control'; @@ -154,13 +155,10 @@ const DataSourcePanel = ({ setList({ columns, metrics }); return; } - const filteredColumns = lists.columns.filter( - column => column.column_name.indexOf(value) !== -1, - ); - const filteredMetrics = lists.metrics.filter( - metric => metric.metric_name.indexOf(value) !== -1, - ); - setList({ columns: filteredColumns, metrics: filteredMetrics }); + setList({ + columns: matchSorter(columns, value, { keys: ['column_name'] }), + metrics: matchSorter(metrics, value, { keys: ['metric_name'] }), + }); }; useEffect(() => { setList({