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

chore: metric refactor iteration 1 #13596

Merged
merged 1 commit into from
Mar 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import AggregateOption from 'src/explore/components/AggregateOption';
import AggregateOption from 'src/explore/components/controls/MetricControl/AggregateOption';

describe('AggregateOption', () => {
it('renders the aggregate', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { shallow } from 'enzyme';
import { ColumnOption, MetricOption } from '@superset-ui/chart-controls';

import MetricDefinitionOption from 'src/explore/components/controls/MetricControl/MetricDefinitionOption';
import AggregateOption from 'src/explore/components/AggregateOption';
import AggregateOption from 'src/explore/components/controls/MetricControl/AggregateOption';

describe('MetricDefinitionOption', () => {
const mockStore = configureStore([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
import ControlHeader from 'src/explore/components/ControlHeader';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import savedMetricType from 'src/explore/components/controls/MetricControl/savedMetricType';
import columnType from 'src/explore/propTypes/columnType';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';
import { OPERATORS } from 'src/explore/constants';
import FilterDefinitionOption from 'src/explore/components/controls/MetricControl/FilterDefinitionOption';
Expand All @@ -40,6 +39,7 @@ import {
LabelsContainer,
} from 'src/explore/components/OptionControls';
import Icon from 'src/components/Icon';
import columnType from './columnType';
import AdhocFilterPopoverTrigger from './AdhocFilterPopoverTrigger';
import AdhocFilterOption from './AdhocFilterOption';
import AdhocFilter, { CLAUSES, EXPRESSION_TYPES } from './AdhocFilter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { styled, t } from '@superset-ui/core';

import ErrorBoundary from 'src/components/ErrorBoundary';
import Tabs from 'src/common/components/Tabs';
import columnType from 'src/explore/propTypes/columnType';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import columnType from './columnType';
import AdhocFilter, { EXPRESSION_TYPES } from './AdhocFilter';
import AdhocFilterEditPopoverSimpleTabContent from './AdhocFilterEditPopoverSimpleTabContent';
import AdhocFilterEditPopoverSqlTabContent from './AdhocFilterEditPopoverSqlTabContent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { Input } from 'src/common/components';
import { t, SupersetClient, styled } from '@superset-ui/core';

import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import columnType from 'src/explore/propTypes/columnType';
import {
OPERATORS,
OPERATORS_OPTIONS,
Expand All @@ -36,6 +35,7 @@ import {
DISABLE_INPUT_OPERATORS,
} from 'src/explore/constants';
import FilterDefinitionOption from 'src/explore/components/controls/MetricControl/FilterDefinitionOption';
import columnType from './columnType';
import AdhocFilter, { EXPRESSION_TYPES, CLAUSES } from './AdhocFilter';

const SelectWithLabel = styled(Select)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { SQLEditor } from 'src/components/AsyncAceEditor';
import sqlKeywords from 'src/SqlLab/utils/sqlKeywords';

import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import columnType from 'src/explore/propTypes/columnType';
import columnType from './columnType';
import AdhocFilter, { EXPRESSION_TYPES, CLAUSES } from './AdhocFilter';

const propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
import columnType from 'src/explore/propTypes/columnType';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import { OptionControlLabel } from 'src/explore/components/OptionControls';
import columnType from './columnType';
import AdhocFilterPopoverTrigger from './AdhocFilterPopoverTrigger';
import AdhocFilter from './AdhocFilter';
import { DndItemType } from '../../DndItemType';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import sqlKeywords from 'src/SqlLab/utils/sqlKeywords';
import { noOp } from 'src/utils/common';

import { AGGREGATES_OPTIONS } from 'src/explore/constants';
import columnType from 'src/explore/propTypes/columnType';
import columnType from './columnType';
import savedMetricType from './savedMetricType';
import AdhocMetric, { EXPRESSION_TYPES } from './AdhocMetric';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
import columnType from 'src/explore/propTypes/columnType';
import { OptionControlLabel } from 'src/explore/components/OptionControls';
import columnType from './columnType';
import AdhocMetric from './AdhocMetric';
import savedMetricType from './savedMetricType';
import AdhocMetricPopoverTrigger from './AdhocMetricPopoverTrigger';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { ColumnTypeLabel } from '@superset-ui/chart-controls';

import aggregateOptionType from '../propTypes/aggregateOptionType';
import aggregateOptionType from './aggregateOptionType';

const propTypes = {
aggregate: aggregateOptionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { ColumnOption, ColumnTypeLabel } from '@superset-ui/chart-controls';

import columnType from 'src/explore/propTypes/columnType';
import columnType from './columnType';
import AdhocMetricStaticOption from './AdhocMetricStaticOption';
import adhocMetricType from './adhocMetricType';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import { ColumnOption, MetricOption } from '@superset-ui/chart-controls';

import AggregateOption from 'src/explore/components/AggregateOption';
import columnType from 'src/explore/propTypes/columnType';
import aggregateOptionType from 'src/explore/propTypes/aggregateOptionType';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import AggregateOption from './AggregateOption';
import columnType from './columnType';
import aggregateOptionType from './aggregateOptionType';
import savedMetricType from './savedMetricType';

const propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Metric } from '@superset-ui/chart-controls/lib/types';
import columnType from 'src/explore/propTypes/columnType';
import columnType from './columnType';
import AdhocMetricOption from './AdhocMetricOption';
import AdhocMetric from './AdhocMetric';
import savedMetricType from './savedMetricType';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import PropTypes from 'prop-types';
import { t, withTheme } from '@superset-ui/core';
import { isEqual } from 'lodash';
import ControlHeader from 'src/explore/components/ControlHeader';
import columnType from 'src/explore/propTypes/columnType';
import {
AGGREGATES_OPTIONS,
sqlaAutoGeneratedMetricNameRegex,
Expand All @@ -34,6 +33,7 @@ import {
HeaderContainer,
LabelsContainer,
} from 'src/explore/components/OptionControls';
import columnType from './columnType';
import MetricDefinitionOption from './MetricDefinitionOption';
import MetricDefinitionValue from './MetricDefinitionValue';
import AdhocMetric from './AdhocMetric';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import PropTypes from 'prop-types';

import { AGGREGATES } from 'src/explore/constants';
import columnType from 'src/explore/propTypes/columnType';
import columnType from './columnType';
import { EXPRESSION_TYPES } from './AdhocMetric';

export default PropTypes.oneOfType([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* 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 PropTypes from 'prop-types';

export default PropTypes.shape({
column_name: PropTypes.string.isRequired,
type: PropTypes.string,
});
Comment on lines +19 to +24
Copy link
Member

Choose a reason for hiding this comment

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

Note to other reviewers: the reason the columnType type is duplicated is to make it possible for these to start diverging in the future.