Skip to content

Commit

Permalink
refactor(explore): move MetricControl and FilterControl to sub-compon…
Browse files Browse the repository at this point in the history
…ent (#12446)

* wip

* wip

* wip

* wip

* move spec

* wip

* wip

* remove unused file

* wip

* wip

* Update superset-frontend/spec/javascripts/explore/components/AdhocFilterEditPopoverSqlTabContent_spec.jsx

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* Update superset-frontend/spec/javascripts/explore/components/AdhocFilterOption_spec.jsx

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* Update superset-frontend/spec/javascripts/explore/components/AdhocMetricEditPopoverTitle_spec.jsx

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
  • Loading branch information
zhaoyongjie and villebro authored Jan 19, 2021
1 parent 84266bf commit 9771b82
Show file tree
Hide file tree
Showing 41 changed files with 130 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
} from 'src/explore/components/controls/FilterControl/AdhocFilter';

describe('AdhocFilter', () => {
it('sets filterOptionName in constructor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
import AdhocMetric, { EXPRESSION_TYPES } from 'src/explore/AdhocMetric';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetric, {
EXPRESSION_TYPES,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';

const valueColumn = { type: 'DOUBLE', column_name: 'value' };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import { supersetTheme } from '@superset-ui/core';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
import AdhocFilterControl from 'src/explore/components/controls/AdhocFilterControl';
} from 'src/explore/components/controls/FilterControl/AdhocFilter';
import { LabelsContainer } from 'src/explore/components/OptionControls';
import AdhocMetric from 'src/explore/AdhocMetric';
import { AGGREGATES, OPERATORS } from 'src/explore/constants';
import AdhocFilterControl from 'src/explore/components/controls/FilterControl/AdhocFilterControl';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';

const simpleAdhocFilter = new AdhocFilter({
expressionType: EXPRESSION_TYPES.SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import { FormGroup } from 'react-bootstrap';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
import AdhocMetric from 'src/explore/AdhocMetric';
import AdhocFilterEditPopoverSimpleTabContent from 'src/explore/components/AdhocFilterEditPopoverSimpleTabContent';
} from 'src/explore/components/controls/FilterControl/AdhocFilter';
import { AGGREGATES } from 'src/explore/constants';
import AdhocFilterEditPopoverSimpleTabContent from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';

const simpleAdhocFilter = new AdhocFilter({
expressionType: EXPRESSION_TYPES.SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { FormGroup } from 'react-bootstrap';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
import AdhocFilterEditPopoverSqlTabContent from 'src/explore/components/AdhocFilterEditPopoverSqlTabContent';
} from 'src/explore/components/controls/FilterControl/AdhocFilter';
import AdhocFilterEditPopoverSqlTabContent from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent';

const sqlAdhocFilter = new AdhocFilter({
expressionType: EXPRESSION_TYPES.SQL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import Tabs from 'src/common/components/Tabs';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
import AdhocMetric from 'src/explore/AdhocMetric';
import AdhocFilterEditPopover from 'src/explore/components/AdhocFilterEditPopover';
import AdhocFilterEditPopoverSimpleTabContent from 'src/explore/components/AdhocFilterEditPopoverSimpleTabContent';
import AdhocFilterEditPopoverSqlTabContent from 'src/explore/components/AdhocFilterEditPopoverSqlTabContent';
} from 'src/explore/components/controls/FilterControl/AdhocFilter';
import { AGGREGATES } from 'src/explore/constants';
import AdhocFilterEditPopover from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopover';
import AdhocFilterEditPopoverSimpleTabContent from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent';
import AdhocFilterEditPopoverSqlTabContent from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';

const simpleAdhocFilter = new AdhocFilter({
expressionType: EXPRESSION_TYPES.SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import Popover from 'src/common/components/Popover';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
import AdhocFilterOption from 'src/explore/components/AdhocFilterOption';
} from 'src/explore/components/controls/FilterControl/AdhocFilter';
import AdhocFilterOption from 'src/explore/components/controls/FilterControl/AdhocFilterOption';

const simpleAdhocFilter = new AdhocFilter({
expressionType: EXPRESSION_TYPES.SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import sinon from 'sinon';
import { shallow } from 'enzyme';
import { Tooltip } from 'src/common/components/Tooltip';

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

const title = {
label: 'Title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import { shallow } from 'enzyme';
import { FormGroup } from 'react-bootstrap';
import Button from 'src/components/Button';

import AdhocMetric, { EXPRESSION_TYPES } from 'src/explore/AdhocMetric';
import AdhocMetricEditPopover from 'src/explore/components/AdhocMetricEditPopover';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetricEditPopover from 'src/explore/components/controls/MetricControl/AdhocMetricEditPopover';
import AdhocMetric, {
EXPRESSION_TYPES,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';

const columns = [
{ type: 'VARCHAR(255)', column_name: 'source', id: 1 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import sinon from 'sinon';
import { shallow } from 'enzyme';

import Popover from 'src/common/components/Popover';
import AdhocMetric from 'src/explore/AdhocMetric';
import AdhocMetricOption from 'src/explore/components/AdhocMetricOption';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetricOption from 'src/explore/components/controls/MetricControl/AdhocMetricOption';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';

const columns = [
{ type: 'VARCHAR(255)', column_name: 'source' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import React from 'react';
import { shallow } from 'enzyme';

import AdhocMetricStaticOption from 'src/explore/components/AdhocMetricStaticOption';
import AdhocMetric, { EXPRESSION_TYPES } from 'src/explore/AdhocMetric';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetricStaticOption from 'src/explore/components/controls/MetricControl/AdhocMetricStaticOption';
import AdhocMetric, {
EXPRESSION_TYPES,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';

const sumValueAdhocMetric = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import React from 'react';
import { shallow } from 'enzyme';

import { ColumnOption } from '@superset-ui/chart-controls';
import FilterDefinitionOption from 'src/explore/components/FilterDefinitionOption';
import AdhocMetricStaticOption from 'src/explore/components/AdhocMetricStaticOption';
import AdhocMetric, { EXPRESSION_TYPES } from 'src/explore/AdhocMetric';
import FilterDefinitionOption from 'src/explore/components/controls/MetricControl/FilterDefinitionOption';
import AdhocMetricStaticOption from 'src/explore/components/controls/MetricControl/AdhocMetricStaticOption';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetric, {
EXPRESSION_TYPES,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';

const sumValueAdhocMetric = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import React from 'react';
import { shallow } from 'enzyme';

import FixedOrMetricControl from 'src/explore/components/controls/FixedOrMetricControl';
import TextControl from 'src/explore/components/controls/TextControl';
import MetricsControl from 'src/explore/components/controls/MetricsControl';
import FixedOrMetricControl from 'src/explore/components/controls/FixedOrMetricControl';
import MetricsControl from 'src/explore/components/controls/MetricControl/MetricsControl';

const defaultProps = {
value: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import configureStore from 'redux-mock-store';
import { shallow } from 'enzyme';
import { ColumnOption, MetricOption } from '@superset-ui/chart-controls';

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

describe('MetricDefinitionOption', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import React from 'react';
import { shallow } from 'enzyme';

import MetricDefinitionValue from 'src/explore/components/MetricDefinitionValue';
import AdhocMetricOption from 'src/explore/components/AdhocMetricOption';
import AdhocMetric from 'src/explore/AdhocMetric';
import { AGGREGATES } from 'src/explore/constants';
import MetricDefinitionValue from 'src/explore/components/controls/MetricControl/MetricDefinitionValue';
import AdhocMetricOption from 'src/explore/components/controls/MetricControl/AdhocMetricOption';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';

const sumValueAdhocMetric = new AdhocMetric({
column: { type: 'DOUBLE', column_name: 'value' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';

import MetricsControl from 'src/explore/components/controls/MetricsControl';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetric, { EXPRESSION_TYPES } from 'src/explore/AdhocMetric';
import { LabelsContainer } from 'src/explore/components/OptionControls';
import { supersetTheme } from '@superset-ui/core';
import MetricsControl from 'src/explore/components/controls/MetricControl/MetricsControl';
import AdhocMetric, {
EXPRESSION_TYPES,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';

const defaultProps = {
name: 'metrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { ReactWrapper } from 'enzyme';
import { styledMount as mount } from 'spec/helpers/theming';
import { act } from 'react-dom/test-utils';

import MetricsControl from 'src/explore/components/controls/MetricsControl';
import withAsyncVerification, {
ControlPropsWithExtras,
WithAsyncVerificationOptions,
} from 'src/explore/components/controls/withAsyncVerification';
import { ExtraControlProps } from '@superset-ui/chart-controls';
import MetricsControl from 'src/explore/components/controls/MetricControl/MetricsControl';

const VALID_METRIC = {
metric_name: 'sum__value',
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/explore/components/OptionControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { findDOMNode } from 'react-dom';
import { DragSource, DropTarget } from 'react-dnd';
import { styled, useTheme } from '@superset-ui/core';
import { ColumnOption } from '@superset-ui/chart-controls';
import Icon from '../../components/Icon';
import { savedMetricType } from '../types';
import Icon from 'src/components/Icon';
import { savedMetricType } from 'src/explore/components/controls/MetricControl/types';

const TYPE = 'label-dnd';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { CUSTOM_OPERATORS } from './constants';
import { getSimpleSQLExpression } from './exploreUtils';
import { CUSTOM_OPERATORS } from 'src/explore/constants';
import { getSimpleSQLExpression } from 'src/explore/exploreUtils';

export const EXPRESSION_TYPES = {
SIMPLE: 'SIMPLE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ import React from 'react';
import PropTypes from 'prop-types';
import { t, logging, SupersetClient, withTheme } from '@superset-ui/core';

import ControlHeader from '../ControlHeader';
import adhocFilterType from '../../propTypes/adhocFilterType';
import adhocMetricType from '../../propTypes/adhocMetricType';
import savedMetricType from '../../propTypes/savedMetricType';
import columnType from '../../propTypes/columnType';
import AdhocFilter, { CLAUSES, EXPRESSION_TYPES } from '../../AdhocFilter';
import AdhocMetric from '../../AdhocMetric';
import { OPERATORS } from '../../constants';
import AdhocFilterOption from '../AdhocFilterOption';
import FilterDefinitionOption from '../FilterDefinitionOption';
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';
import {
AddControlLabel,
AddIconButton,
HeaderContainer,
LabelsContainer,
} from '../OptionControls';
import Icon from '../../../components/Icon';
import AdhocFilterPopoverTrigger from '../AdhocFilterPopoverTrigger';
import DndWithHTML5Backend from '../../DndContextProvider';
} from 'src/explore/components/OptionControls';
import Icon from 'src/components/Icon';
import DndWithHTML5Backend from 'src/explore/DndContextProvider';
import AdhocFilterPopoverTrigger from './AdhocFilterPopoverTrigger';
import AdhocFilterOption from './AdhocFilterOption';
import AdhocFilter, { CLAUSES, EXPRESSION_TYPES } from './AdhocFilter';
import adhocFilterType from './adhocFilterType';

const propTypes = {
name: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { styled, t } from '@superset-ui/core';

import ErrorBoundary from 'src/components/ErrorBoundary';
import Tabs from 'src/common/components/Tabs';
import columnType from '../propTypes/columnType';
import adhocMetricType from '../propTypes/adhocMetricType';
import AdhocFilter, { EXPRESSION_TYPES } from '../AdhocFilter';
import columnType from 'src/explore/propTypes/columnType';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
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 @@ -23,9 +23,8 @@ import { Select } from 'src/common/components/Select';
import { Input } from 'src/common/components';
import { t, SupersetClient, styled } from '@superset-ui/core';

import AdhocFilter, { EXPRESSION_TYPES, CLAUSES } from '../AdhocFilter';
import adhocMetricType from '../propTypes/adhocMetricType';
import columnType from '../propTypes/columnType';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import columnType from 'src/explore/propTypes/columnType';
import {
OPERATORS,
OPERATORS_OPTIONS,
Expand All @@ -35,8 +34,9 @@ import {
MULTI_OPERATORS,
CUSTOM_OPERATORS,
DISABLE_INPUT_OPERATORS,
} from '../constants';
import FilterDefinitionOption from './FilterDefinitionOption';
} from 'src/explore/constants';
import FilterDefinitionOption from 'src/explore/components/controls/MetricControl/FilterDefinitionOption';
import AdhocFilter, { EXPRESSION_TYPES, CLAUSES } from './AdhocFilter';

const SelectWithLabel = styled(Select)`
.ant-select-selector::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import { t } from '@superset-ui/core';
import { SQLEditor } from 'src/components/AsyncAceEditor';
import sqlKeywords from 'src/SqlLab/utils/sqlKeywords';

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

const propTypes = {
adhocFilter: PropTypes.instanceOf(AdhocFilter).isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
import AdhocFilter from '../AdhocFilter';
import columnType from '../propTypes/columnType';
import adhocMetricType from '../propTypes/adhocMetricType';
import columnType from 'src/explore/propTypes/columnType';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import { DraggableOptionControlLabel } from 'src/explore/components/OptionControls';
import { OPTION_TYPES } from 'src/explore/components/optionTypes';
import AdhocFilterPopoverTrigger from './AdhocFilterPopoverTrigger';
import { DraggableOptionControlLabel } from './OptionControls';
import { OPTION_TYPES } from './optionTypes';
import AdhocFilter from './AdhocFilter';

const propTypes = {
adhocFilter: PropTypes.instanceOf(AdhocFilter).isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { t } from '@superset-ui/core';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';

import Popover from 'src/common/components/Popover';
import columnType from 'src/explore/propTypes/columnType';
import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import AdhocFilterEditPopover from './AdhocFilterEditPopover';
import AdhocFilter from '../AdhocFilter';
import columnType from '../propTypes/columnType';
import adhocMetricType from '../propTypes/adhocMetricType';
import AdhocFilter from './AdhocFilter';

interface AdhocFilterPopoverTriggerProps {
adhocFilter: AdhocFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
import PropTypes from 'prop-types';

import { OPERATORS } from '../constants';
import { EXPRESSION_TYPES, CLAUSES } from '../AdhocFilter';
import { OPERATORS } from 'src/explore/constants';
import { EXPRESSION_TYPES, CLAUSES } from './AdhocFilter';

export default PropTypes.oneOfType([
PropTypes.shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Panel } from 'react-bootstrap';

import Label from 'src/components/Label';
import TextControl from './TextControl';
import MetricsControl from './MetricsControl';
import MetricsControl from './MetricControl/MetricsControl';
import ControlHeader from '../ControlHeader';
import PopoverSection from '../../../components/PopoverSection';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { sqlaAutoGeneratedMetricRegex } from './constants';
import { sqlaAutoGeneratedMetricRegex } from 'src/explore/constants';

export const EXPRESSION_TYPES = {
SIMPLE: 'SIMPLE',
Expand Down
Loading

0 comments on commit 9771b82

Please sign in to comment.