refactor: Migrate react-select to Antd Select in Metrics and Filters popovers (#12042)

* Migrate react-select to Antd select in Metrics popover

* Fix tests

* Migrate react-select to Antd select in Filters popover

* Migrate SelectControl to Antd Select

* Add label with number of options left
This commit is contained in:
Kamil Gabryjelski
2020-12-16 06:20:10 +01:00
committed by GitHub
parent 8bda6b0bd9
commit 794d318989
7 changed files with 139 additions and 95 deletions

View File

@@ -59,10 +59,10 @@ const simpleCustomFilter = new AdhocFilter({
});
const options = [
{ type: 'VARCHAR(255)', column_name: 'source' },
{ type: 'VARCHAR(255)', column_name: 'target' },
{ type: 'DOUBLE', column_name: 'value' },
{ saved_metric_name: 'my_custom_metric' },
{ type: 'VARCHAR(255)', column_name: 'source', id: 1 },
{ type: 'VARCHAR(255)', column_name: 'target', id: 2 },
{ type: 'DOUBLE', column_name: 'value', id: 3 },
{ saved_metric_name: 'my_custom_metric', id: 4 },
sumValueAdhocMetric,
];
@@ -91,9 +91,7 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
it('passes the new adhocFilter to onChange after onSubjectChange', () => {
const { wrapper, onChange } = setup();
wrapper
.instance()
.onSubjectChange({ type: 'VARCHAR(255)', column_name: 'source' });
wrapper.instance().onSubjectChange(1);
expect(onChange.calledOnce).toBe(true);
expect(onChange.lastCall.args[0]).toEqual(
simpleAdhocFilter.duplicateWith({ subject: 'source' }),
@@ -102,7 +100,7 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
it('may alter the clause in onSubjectChange if the old clause is not appropriate', () => {
const { wrapper, onChange } = setup();
wrapper.instance().onSubjectChange(sumValueAdhocMetric);
wrapper.instance().onSubjectChange(sumValueAdhocMetric.optionName);
expect(onChange.calledOnce).toBe(true);
expect(onChange.lastCall.args[0]).toEqual(
simpleAdhocFilter.duplicateWith({

View File

@@ -28,9 +28,9 @@ import AdhocMetricEditPopover from 'src/explore/components/AdhocMetricEditPopove
import { AGGREGATES } from 'src/explore/constants';
const columns = [
{ type: 'VARCHAR(255)', column_name: 'source' },
{ type: 'VARCHAR(255)', column_name: 'target' },
{ type: 'DOUBLE', column_name: 'value' },
{ type: 'VARCHAR(255)', column_name: 'source', id: 1 },
{ type: 'VARCHAR(255)', column_name: 'target', id: 2 },
{ type: 'DOUBLE', column_name: 'value', id: 3 },
];
const sumValueAdhocMetric = new AdhocMetric({
@@ -68,7 +68,7 @@ describe('AdhocMetricEditPopover', () => {
it('overwrites the adhocMetric in state with onColumnChange', () => {
const { wrapper } = setup();
wrapper.instance().onColumnChange(columns[0]);
wrapper.instance().onColumnChange(columns[0].id);
expect(wrapper.state('adhocMetric')).toEqual(
sumValueAdhocMetric.duplicateWith({ column: columns[0] }),
);
@@ -95,7 +95,7 @@ describe('AdhocMetricEditPopover', () => {
expect(wrapper.find(Button).find({ disabled: true })).not.toExist();
wrapper.instance().onColumnChange(null);
expect(wrapper.find(Button).find({ disabled: true })).toExist();
wrapper.instance().onColumnChange({ column: columns[0] });
wrapper.instance().onColumnChange(columns[0].id);
expect(wrapper.find(Button).find({ disabled: true })).not.toExist();
wrapper.instance().onAggregateChange(null);
expect(wrapper.find(Button).find({ disabled: true })).toExist();
@@ -104,7 +104,7 @@ describe('AdhocMetricEditPopover', () => {
it('highlights save if changes are present', () => {
const { wrapper } = setup();
expect(wrapper.find(Button).find({ buttonStyle: 'primary' })).not.toExist();
wrapper.instance().onColumnChange({ column: columns[1] });
wrapper.instance().onColumnChange(columns[1].id);
expect(wrapper.find(Button).find({ buttonStyle: 'primary' })).toExist();
});