diff --git a/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx b/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx index 9aa553ca88..8afc9900bf 100644 --- a/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx +++ b/superset/assets/spec/javascripts/explore/components/MetricsControl_spec.jsx @@ -224,7 +224,7 @@ describe('MetricsControl', () => { expect(!!wrapper.instance().selectFilterOption( { type: 'VARCHAR(255)', column_name: 'source', optionName: '_col_source' }, - 'Sou', + 'sou', )).to.be.true; expect(!!wrapper.instance().selectFilterOption( @@ -233,6 +233,15 @@ describe('MetricsControl', () => { )).to.be.true; }); + it('includes columns based on verbose_name', () => { + const { wrapper } = setup(); + + expect(!!wrapper.instance().selectFilterOption( + { metric_name: 'sum__num', verbose_name: 'babies', optionName: '_col_sum_num' }, + 'bab', + )).to.be.true; + }); + it('excludes auto generated avg metrics for sqla', () => { const { wrapper } = setup(); diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx b/superset/assets/src/explore/components/controls/MetricsControl.jsx index bc0b72a4da..d195cdb1ae 100644 --- a/superset/assets/src/explore/components/controls/MetricsControl.jsx +++ b/superset/assets/src/explore/components/controls/MetricsControl.jsx @@ -221,11 +221,15 @@ export default class MetricsControl extends React.PureComponent { } const valueAfterAggregate = filterValue.substring(filterValue.indexOf('(') + 1, endIndex); return option.column_name && - (option.column_name.toLowerCase().indexOf(valueAfterAggregate.toLowerCase()) >= 0); + (option.column_name.toLowerCase().indexOf(valueAfterAggregate) >= 0); } return option.optionName && - (!option.metric_name || !this.isAutoGeneratedMetric(option)) && - (option.optionName.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0); + (!option.metric_name || !this.isAutoGeneratedMetric(option) || option.verbose_name) && ( + option.optionName.toLowerCase().indexOf(filterValue) >= 0 || + ( + option.verbose_name && option.verbose_name.toLowerCase().indexOf(filterValue) >= 0 + ) + ); } render() { diff --git a/superset/assets/src/explore/components/controls/SelectControl.jsx b/superset/assets/src/explore/components/controls/SelectControl.jsx index 64fc9e60d1..4f1e8da469 100644 --- a/superset/assets/src/explore/components/controls/SelectControl.jsx +++ b/superset/assets/src/explore/components/controls/SelectControl.jsx @@ -28,6 +28,7 @@ const propTypes = { placeholder: PropTypes.string, noResultsText: PropTypes.string, refFunc: PropTypes.func, + filterOption: PropTypes.func, }; const defaultProps = { @@ -131,6 +132,7 @@ export default class SelectControl extends React.PureComponent { selectComponent: this.props.freeForm ? Creatable : Select, disabled: this.props.disabled, refFunc: this.props.refFunc, + filterOption: this.props.filterOption, }; return (