Skip to content

Commit

Permalink
Uses a named export for propertyComparator
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Oct 22, 2021
1 parent bd3f4e9 commit 4af7286
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 17 deletions.
4 changes: 1 addition & 3 deletions superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const defaultSortComparator = (a: AntdLabeledValue, b: AntdLabeledValue) => {
* It creates a comparator to check for a specific property.
* Can be used with string and number property values.
* */
const propertyComparator = (property: string) => (
export const propertyComparator = (property: string) => (
a: AntdLabeledValue,
b: AntdLabeledValue,
) => {
Expand Down Expand Up @@ -684,6 +684,4 @@ const Select = ({
);
};

Select.propertyComparator = propertyComparator;

export default Select;
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
* under the License.
*/
import React, { RefObject } from 'react';
import { Select } from 'src/components';
import Select, { propertyComparator } from 'src/components/Select/Select';
import { t, styled } from '@superset-ui/core';
import Alert from 'src/components/Alert';
import Button from 'src/components/Button';

import ModalTrigger from 'src/components/ModalTrigger';
import { FormLabel } from 'src/components/Form';

const { propertyComparator } = Select;

export const options = [
[0, t("Don't refresh")],
[10, t('10 seconds')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React from 'react';
import { styled, t } from '@superset-ui/core';
import { Form, FormItem, FormProps } from 'src/components/Form';
import { Select } from 'src/components';
import Select, { propertyComparator } from 'src/components/Select/Select';
import { Col, InputNumber, Row } from 'src/common/components';
import Button from 'src/components/Button';
import {
Expand All @@ -28,8 +28,6 @@ import {
MULTIPLE_VALUE_COMPARATORS,
} from './types';

const { propertyComparator } = Select;

const FullWidthInputNumber = styled(InputNumber)`
width: 100%;
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import Label, { Type } from 'src/components/Label';
import Popover from 'src/components/Popover';
import { Divider } from 'src/common/components';
import Icons from 'src/components/Icons';
import { Select } from 'src/components';
import Select, { propertyComparator } from 'src/components/Select/Select';
import { Tooltip } from 'src/components/Tooltip';
import { DEFAULT_TIME_RANGE } from 'src/explore/constants';
import { useDebouncedEffect } from 'src/explore/exploreUtils';
Expand All @@ -55,8 +55,6 @@ import {
AdvancedFrame,
} from './components';

const { propertyComparator } = Select;

const guessFrame = (timeRange: string): FrameType => {
if (COMMON_RANGE_VALUES_SET.has(timeRange)) {
return 'Common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { isInteger } from 'lodash';
import { Col, InputNumber, Row } from 'src/common/components';
import { DatePicker } from 'src/components/DatePicker';
import { Radio } from 'src/components/Radio';
import { Select } from 'src/components';
import Select, { propertyComparator } from 'src/components/Select/Select';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import {
SINCE_GRAIN_OPTIONS,
Expand All @@ -41,7 +41,6 @@ import {
FrameComponentProps,
} from 'src/explore/components/controls/DateFilterControl/types';

const { propertyComparator } = Select;
const sortComparator = propertyComparator('order');

export function CustomFrame(props: FrameComponentProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jest.mock('src/components/Select/Select', () => ({
</button>
</div>
),
propertyComparator: jest.fn(),
}));

fetchMock.get(datasetsOwnersEndpoint, {
Expand Down
4 changes: 1 addition & 3 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { Switch } from 'src/components/Switch';
import Modal from 'src/components/Modal';
import TimezoneSelector from 'src/components/TimezoneSelector';
import { Radio } from 'src/components/Radio';
import { Select } from 'src/components';
import Select, { propertyComparator } from 'src/components/Select/Select';
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import withToasts from 'src/components/MessageToasts/withToasts';
import Owner from 'src/types/Owner';
Expand All @@ -57,8 +57,6 @@ import {
import { AlertReportCronScheduler } from './components/AlertReportCronScheduler';
import { NotificationMethod } from './components/NotificationMethod';

const { propertyComparator } = Select;

const TIMEOUT_MIN = 1;
const TEXT_BASED_VISUALIZATION_TYPES = [
'pivot_table',
Expand Down

0 comments on commit 4af7286

Please sign in to comment.