diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json
index 712314643..f80cb17be 100644
--- a/superset-frontend/package-lock.json
+++ b/superset-frontend/package-lock.json
@@ -7776,12 +7776,13 @@
}
},
"@superset-ui/control-utils": {
- "version": "0.13.27",
- "resolved": "https://registry.npmjs.org/@superset-ui/control-utils/-/control-utils-0.13.27.tgz",
- "integrity": "sha512-tM3fcFaHhpZ/6erh/I/PJhcgU/jZhLHJOwLoxvDJDNNabf/M9+2TbwOaK/91buiJadQrkBzAOOgGIjb02UrKLA==",
+ "version": "0.13.29",
+ "resolved": "https://registry.npmjs.org/@superset-ui/control-utils/-/control-utils-0.13.29.tgz",
+ "integrity": "sha512-COfXjB9JPYZlJ+gSDpv00sVGxnrRSV0l4NhIXFhH8KRmu7N8Vr/5sj3X47jQnRV/4TGclRVVEJV9bOYea7Hb+A==",
"requires": {
"@types/react-bootstrap": "0.32.21",
"lodash": "^4.17.15",
+ "prop-types": "^15.7.2",
"react-bootstrap": "^0.33.1"
}
},
@@ -7837,6 +7838,16 @@
"prop-types": "^15.6.2"
},
"dependencies": {
+ "@superset-ui/control-utils": {
+ "version": "0.13.27",
+ "resolved": "https://registry.npmjs.org/@superset-ui/control-utils/-/control-utils-0.13.27.tgz",
+ "integrity": "sha512-tM3fcFaHhpZ/6erh/I/PJhcgU/jZhLHJOwLoxvDJDNNabf/M9+2TbwOaK/91buiJadQrkBzAOOgGIjb02UrKLA==",
+ "requires": {
+ "@types/react-bootstrap": "0.32.21",
+ "lodash": "^4.17.15",
+ "react-bootstrap": "^0.33.1"
+ }
+ },
"d3-array": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.4.0.tgz",
@@ -8412,6 +8423,16 @@
"@superset-ui/validator": "0.13.27"
},
"dependencies": {
+ "@superset-ui/control-utils": {
+ "version": "0.13.27",
+ "resolved": "https://registry.npmjs.org/@superset-ui/control-utils/-/control-utils-0.13.27.tgz",
+ "integrity": "sha512-tM3fcFaHhpZ/6erh/I/PJhcgU/jZhLHJOwLoxvDJDNNabf/M9+2TbwOaK/91buiJadQrkBzAOOgGIjb02UrKLA==",
+ "requires": {
+ "@types/react-bootstrap": "0.32.21",
+ "lodash": "^4.17.15",
+ "react-bootstrap": "^0.33.1"
+ }
+ },
"@superset-ui/style": {
"version": "0.13.27",
"resolved": "https://registry.npmjs.org/@superset-ui/style/-/style-0.13.27.tgz",
diff --git a/superset-frontend/package.json b/superset-frontend/package.json
index df020996f..7d60f6ba2 100644
--- a/superset-frontend/package.json
+++ b/superset-frontend/package.json
@@ -63,7 +63,7 @@
"@superset-ui/chart-composition": "^0.13.27",
"@superset-ui/color": "^0.13.27",
"@superset-ui/connection": "^0.13.27",
- "@superset-ui/control-utils": "^0.13.27",
+ "@superset-ui/control-utils": "^0.13.28",
"@superset-ui/core": "^0.13.27",
"@superset-ui/dimension": "^0.13.27",
"@superset-ui/legacy-plugin-chart-calendar": "^0.13.27",
diff --git a/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx b/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx
index 0acb7bd08..76b4db90f 100644
--- a/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx
+++ b/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx
@@ -19,8 +19,7 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { ColumnOption } from '@superset-ui/control-utils';
-import ColumnTypeLabel from 'src/components/ColumnTypeLabel';
+import { ColumnOption, ColumnTypeLabel } from '@superset-ui/control-utils';
describe('ColumnOption', () => {
const defaultProps = {
diff --git a/superset-frontend/spec/javascripts/components/MetricOption_spec.jsx b/superset-frontend/spec/javascripts/components/MetricOption_spec.jsx
deleted file mode 100644
index 1ab8314d1..000000000
--- a/superset-frontend/spec/javascripts/components/MetricOption_spec.jsx
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import { InfoTooltipWithTrigger } from '@superset-ui/control-utils';
-
-import MetricOption from 'src/components/MetricOption';
-import ColumnTypeLabel from 'src/components/ColumnTypeLabel';
-
-describe('MetricOption', () => {
- const defaultProps = {
- metric: {
- metric_name: 'foo',
- verbose_name: 'Foo',
- expression: 'SUM(foo)',
- description: 'Foo is the greatest metric of all',
- warning_text: 'Be careful when using foo',
- },
- showType: false,
- };
-
- let wrapper;
- let props;
- const factory = o => ;
- beforeEach(() => {
- wrapper = shallow(factory(defaultProps));
- props = { ...defaultProps };
- });
- it('is a valid element', () => {
- expect(React.isValidElement()).toBe(true);
- });
- it('shows a label with verbose_name', () => {
- const lbl = wrapper.find('.option-label');
- expect(lbl).toHaveLength(1);
- expect(lbl.first().text()).toBe('Foo');
- });
- it('shows 3 InfoTooltipWithTrigger', () => {
- expect(wrapper.find(InfoTooltipWithTrigger)).toHaveLength(3);
- });
- it('shows only 2 InfoTooltipWithTrigger when no descr', () => {
- props.metric.description = null;
- wrapper = shallow(factory(props));
- expect(wrapper.find(InfoTooltipWithTrigger)).toHaveLength(2);
- });
- it('shows a label with metric_name when no verbose_name', () => {
- props.metric.verbose_name = null;
- wrapper = shallow(factory(props));
- expect(wrapper.find('.option-label').first().text()).toBe('foo');
- });
- it('shows only 1 InfoTooltipWithTrigger when no descr and no warning', () => {
- props.metric.warning_text = null;
- wrapper = shallow(factory(props));
- expect(wrapper.find(InfoTooltipWithTrigger)).toHaveLength(1);
- });
- it('sets target="_blank" when openInNewWindow is true', () => {
- props.url = 'https://github.com/apache/incubator-superset';
- wrapper = shallow(factory(props));
- expect(wrapper.find('a').prop('target')).toBeNull();
-
- props.openInNewWindow = true;
- wrapper = shallow(factory(props));
- expect(wrapper.find('a').prop('target')).toBe('_blank');
- });
- it('shows a metric type label when showType is true', () => {
- props.showType = true;
- wrapper = shallow(factory(props));
- expect(wrapper.find(ColumnTypeLabel)).toHaveLength(1);
- });
-});
diff --git a/superset-frontend/spec/javascripts/explore/components/MetricDefinitionOption_spec.jsx b/superset-frontend/spec/javascripts/explore/components/MetricDefinitionOption_spec.jsx
index d0271fad4..e6bab2d37 100644
--- a/superset-frontend/spec/javascripts/explore/components/MetricDefinitionOption_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/MetricDefinitionOption_spec.jsx
@@ -19,10 +19,9 @@
import React from 'react';
import configureStore from 'redux-mock-store';
import { shallow } from 'enzyme';
+import { ColumnOption, MetricOption } from '@superset-ui/control-utils';
-import { ColumnOption } from '@superset-ui/control-utils';
import MetricDefinitionOption from 'src/explore/components/MetricDefinitionOption';
-import MetricOption from 'src/components/MetricOption';
import AggregateOption from 'src/explore/components/AggregateOption';
describe('MetricDefinitionOption', () => {
diff --git a/superset-frontend/spec/javascripts/explore/components/MetricDefinitionValue_spec.jsx b/superset-frontend/spec/javascripts/explore/components/MetricDefinitionValue_spec.jsx
index 84f7548e5..0da63ef5a 100644
--- a/superset-frontend/spec/javascripts/explore/components/MetricDefinitionValue_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/MetricDefinitionValue_spec.jsx
@@ -19,9 +19,9 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import { shallow } from 'enzyme';
+import { MetricOption } from '@superset-ui/control-utils';
import MetricDefinitionValue from 'src/explore/components/MetricDefinitionValue';
-import MetricOption from 'src/components/MetricOption';
import AdhocMetricOption from 'src/explore/components/AdhocMetricOption';
import AdhocMetric from 'src/explore/AdhocMetric';
import { AGGREGATES } from 'src/explore/constants';
diff --git a/superset-frontend/src/components/ColumnTypeLabel.jsx b/superset-frontend/src/components/ColumnTypeLabel.jsx
deleted file mode 100644
index f378fccff..000000000
--- a/superset-frontend/src/components/ColumnTypeLabel.jsx
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-
-const propTypes = {
- type: PropTypes.string,
-};
-
-export default function ColumnTypeLabel({ type }) {
- let stringIcon = '';
- if (typeof type !== 'string') {
- stringIcon = '?';
- } else if (type === '' || type === 'expression') {
- stringIcon = 'ƒ';
- } else if (type === 'aggregate') {
- stringIcon = 'AGG';
- } else if (
- type.match(/.*char.*/i) ||
- type.match(/string.*/i) ||
- type.match(/.*text.*/i)
- ) {
- stringIcon = 'ABC';
- } else if (
- type.match(/.*int.*/i) ||
- type === 'LONG' ||
- type === 'DOUBLE' ||
- type === 'FLOAT'
- ) {
- stringIcon = '#';
- } else if (type.match(/.*bool.*/i)) {
- stringIcon = 'T/F';
- } else if (type.match(/.*time.*/i)) {
- stringIcon = 'time';
- } else if (type.match(/unknown/i)) {
- stringIcon = '?';
- }
-
- const typeIcon =
- stringIcon === 'time' ? (
-
- ) : (
-
{stringIcon}
- );
-
- return {typeIcon};
-}
-ColumnTypeLabel.propTypes = propTypes;
diff --git a/superset-frontend/src/components/MetricOption.jsx b/superset-frontend/src/components/MetricOption.jsx
deleted file mode 100644
index de5657932..000000000
--- a/superset-frontend/src/components/MetricOption.jsx
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import { InfoTooltipWithTrigger } from '@superset-ui/control-utils';
-import ColumnTypeLabel from './ColumnTypeLabel';
-
-const propTypes = {
- metric: PropTypes.object.isRequired,
- openInNewWindow: PropTypes.bool,
- showFormula: PropTypes.bool,
- showType: PropTypes.bool,
- url: PropTypes.string,
-};
-const defaultProps = {
- showFormula: true,
- showType: false,
-};
-
-export default function MetricOption({
- metric,
- openInNewWindow,
- showFormula,
- showType,
- url,
-}) {
- const verbose = metric.verbose_name || metric.metric_name || metric.label;
- const link = url ? (
-
- {verbose}
-
- ) : (
- verbose
- );
- return (
-
- {showType && }
- {link}
- {metric.description && (
-
- )}
- {showFormula && (
-
- )}
- {metric.warning_text && (
-
- )}
-
- );
-}
-MetricOption.propTypes = propTypes;
-MetricOption.defaultProps = defaultProps;
diff --git a/superset-frontend/src/explore/components/AdhocMetricStaticOption.jsx b/superset-frontend/src/explore/components/AdhocMetricStaticOption.jsx
index 9027b532d..06adce2c3 100644
--- a/superset-frontend/src/explore/components/AdhocMetricStaticOption.jsx
+++ b/superset-frontend/src/explore/components/AdhocMetricStaticOption.jsx
@@ -18,8 +18,8 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
+import { ColumnTypeLabel } from '@superset-ui/control-utils';
-import ColumnTypeLabel from '../../components/ColumnTypeLabel';
import adhocMetricType from '../propTypes/adhocMetricType';
const propTypes = {
diff --git a/superset-frontend/src/explore/components/AggregateOption.jsx b/superset-frontend/src/explore/components/AggregateOption.jsx
index 6170f6d13..8b217b62c 100644
--- a/superset-frontend/src/explore/components/AggregateOption.jsx
+++ b/superset-frontend/src/explore/components/AggregateOption.jsx
@@ -18,8 +18,8 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
+import { ColumnTypeLabel } from '@superset-ui/control-utils';
-import ColumnTypeLabel from '../../components/ColumnTypeLabel';
import aggregateOptionType from '../propTypes/aggregateOptionType';
const propTypes = {
diff --git a/superset-frontend/src/explore/components/FilterDefinitionOption.jsx b/superset-frontend/src/explore/components/FilterDefinitionOption.jsx
index 8028adebf..fa4eb4aab 100644
--- a/superset-frontend/src/explore/components/FilterDefinitionOption.jsx
+++ b/superset-frontend/src/explore/components/FilterDefinitionOption.jsx
@@ -18,9 +18,8 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
-import { ColumnOption } from '@superset-ui/control-utils';
+import { ColumnOption, ColumnTypeLabel } from '@superset-ui/control-utils';
-import ColumnTypeLabel from '../../components/ColumnTypeLabel';
import AdhocMetricStaticOption from './AdhocMetricStaticOption';
import columnType from '../propTypes/columnType';
import adhocMetricType from '../propTypes/adhocMetricType';
diff --git a/superset-frontend/src/explore/components/MetricDefinitionOption.jsx b/superset-frontend/src/explore/components/MetricDefinitionOption.jsx
index 8481bc31b..1c51580a0 100644
--- a/superset-frontend/src/explore/components/MetricDefinitionOption.jsx
+++ b/superset-frontend/src/explore/components/MetricDefinitionOption.jsx
@@ -18,9 +18,8 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
-import { ColumnOption } from '@superset-ui/control-utils';
+import { ColumnOption, MetricOption } from '@superset-ui/control-utils';
-import MetricOption from '../../components/MetricOption';
import AggregateOption from './AggregateOption';
import columnType from '../propTypes/columnType';
import savedMetricType from '../propTypes/savedMetricType';
diff --git a/superset-frontend/src/explore/components/MetricDefinitionValue.jsx b/superset-frontend/src/explore/components/MetricDefinitionValue.jsx
index edadf7f32..d44c62dd5 100644
--- a/superset-frontend/src/explore/components/MetricDefinitionValue.jsx
+++ b/superset-frontend/src/explore/components/MetricDefinitionValue.jsx
@@ -18,11 +18,11 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
+import { MetricOption } from '@superset-ui/control-utils';
import AdhocMetricOption from './AdhocMetricOption';
import AdhocMetric from '../AdhocMetric';
import columnType from '../propTypes/columnType';
-import MetricOption from '../../components/MetricOption';
import savedMetricType from '../propTypes/savedMetricType';
import adhocMetricType from '../propTypes/adhocMetricType';
diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl.jsx b/superset-frontend/src/explore/components/controls/DatasourceControl.jsx
index de652bce7..bdf0f46d0 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl.jsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl.jsx
@@ -30,9 +30,8 @@ import {
Well,
} from 'react-bootstrap';
import { t } from '@superset-ui/translation';
-import { ColumnOption } from '@superset-ui/control-utils';
+import { ColumnOption, MetricOption } from '@superset-ui/control-utils';
import ControlHeader from '../ControlHeader';
-import MetricOption from '../../../components/MetricOption';
import DatasourceModal from '../../../datasource/DatasourceModal';
import ChangeDatasourceModal from '../../../datasource/ChangeDatasourceModal';
import TooltipWrapper from '../../../components/TooltipWrapper';
diff --git a/superset-frontend/src/visualizations/TimeTable/TimeTable.jsx b/superset-frontend/src/visualizations/TimeTable/TimeTable.jsx
index 866dc7a51..0c73d5971 100644
--- a/superset-frontend/src/visualizations/TimeTable/TimeTable.jsx
+++ b/superset-frontend/src/visualizations/TimeTable/TimeTable.jsx
@@ -24,9 +24,11 @@ import { Table, Thead, Th, Tr, Td } from 'reactable-arc';
import { formatNumber } from '@superset-ui/number-format';
import { formatTime } from '@superset-ui/time-format';
import moment from 'moment';
-import { InfoTooltipWithTrigger } from '@superset-ui/control-utils';
+import {
+ InfoTooltipWithTrigger,
+ MetricOption,
+} from '@superset-ui/control-utils';
-import MetricOption from '../../components/MetricOption';
import FormattedNumber from './FormattedNumber';
import SparklineCell from './SparklineCell';
import './TimeTable.less';