Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update search in datasource panel to use matchSorter #12319

Merged
merged 2 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 5 additions & 7 deletions superset-frontend/src/explore/components/DatasourcePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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'] }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to search by SQL expression and data type as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean searching metrics and columns properties, which users can't really see?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But I think they do have a way to see both. For metric definition, there is an info icon tooltip, for data type there is an icon (maybe not that useful than the metric definition, though).

});
};
useEffect(() => {
setList({
Expand Down