Skip to content

Commit

Permalink
chore: Removes Select duplication (#13477)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Mar 31, 2021
1 parent 11dd249 commit 8ddcba8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import fetchMock from 'fetch-mock';
import { act } from 'react-dom/test-utils';
import AlertReportModal from 'src/views/CRUD/alert/AlertReportModal';
import Modal from 'src/common/components/Modal';
import { AsyncSelect } from 'src/components/Select';
import { AsyncSelect, NativeGraySelect as Select } from 'src/components/Select';
import { Radio } from 'src/common/components/Radio';
import { GraySelect as Select } from 'src/common/components/Select';
import { Switch } from 'src/common/components/Switch';
import TextAreaControl from 'src/explore/components/controls/TextAreaControl';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@
*/
import React from 'react';
import { styled } from '@superset-ui/core';
import { Select as BaseSelect, SelectProps } from 'src/common/components';
import Select, { SelectProps } from 'antd/lib/select';

const StyledSelect = styled((props: SelectProps<any>) => (
<BaseSelect
getPopupContainer={(trigger: any) => trigger.parentNode}
{...props}
/>
const StyledNativeSelect = styled((props: SelectProps<any>) => (
<Select getPopupContainer={(trigger: any) => trigger.parentNode} {...props} />
))`
display: block;
`;

const StyledGraySelect = styled(StyledSelect)`
const StyledNativeGraySelect = styled(Select)`
&.ant-select-single {
.ant-select-selector {
height: 36px;
Expand All @@ -49,12 +46,11 @@ const StyledGraySelect = styled(StyledSelect)`
}
}
`;
const StyledOption = BaseSelect.Option;

export const Select = Object.assign(StyledSelect, {
Option: StyledOption,
export const NativeSelect = Object.assign(StyledNativeSelect, {
Option: Select.Option,
});

export const GraySelect = Object.assign(StyledGraySelect, {
Option: StyledOption,
export const NativeGraySelect = Object.assign(StyledNativeGraySelect, {
Option: Select.Option,
});
1 change: 1 addition & 0 deletions superset-frontend/src/components/Select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './Select';
export * from './styles';
export { default } from './Select';
export { default as OnPasteSelect } from './OnPasteSelect';
export { NativeSelect, NativeGraySelect } from './NativeSelect';
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 { FormGroup } from 'react-bootstrap';
import { Select } from 'src/common/components/Select';
import { NativeSelect as Select } from 'src/components/Select';
import { Input } from 'src/common/components';
import { t, SupersetClient, styled } from '@superset-ui/core';

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 { FormGroup } from 'react-bootstrap';
import { Select } from 'src/common/components/Select';
import { NativeSelect as Select } from 'src/components/Select';
import { t } from '@superset-ui/core';
import { SQLEditor } from 'src/components/AsyncAceEditor';
import sqlKeywords from 'src/SqlLab/utils/sqlKeywords';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import PropTypes from 'prop-types';
import { FormGroup } from 'react-bootstrap';
import Tabs from 'src/common/components/Tabs';
import Button from 'src/components/Button';
import { Select } from 'src/common/components/Select';
import { NativeSelect as Select } from 'src/components/Select';
import { styled, t } from '@superset-ui/core';
import { ColumnOption, MetricOption } from '@superset-ui/chart-controls';

Expand Down
3 changes: 1 addition & 2 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import { useSingleViewResource } from 'src/views/CRUD/hooks';
import Icon from 'src/components/Icon';
import Modal from 'src/common/components/Modal';
import { Switch } from 'src/common/components/Switch';
import { GraySelect as Select } from 'src/common/components/Select';
import { Radio } from 'src/common/components/Radio';
import { AsyncSelect } from 'src/components/Select';
import { AsyncSelect, NativeGraySelect as Select } from 'src/components/Select';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import Owner from 'src/types/Owner';
import TextAreaControl from 'src/explore/components/controls/TextAreaControl';
Expand Down

0 comments on commit 8ddcba8

Please sign in to comment.