From 4af728607b152449f5525b79eb9e030c2f3735c1 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Fri, 22 Oct 2021 14:02:10 -0300 Subject: [PATCH] Uses a named export for propertyComparator --- superset-frontend/src/components/Select/Select.tsx | 4 +--- .../src/dashboard/components/RefreshIntervalModal.tsx | 4 +--- .../ConditionalFormattingControl/FormattingPopoverContent.tsx | 4 +--- .../components/controls/DateFilterControl/DateFilterLabel.tsx | 4 +--- .../controls/DateFilterControl/components/CustomFrame.tsx | 3 +-- .../controls/SelectAsyncControl/SelectAsyncControl.test.tsx | 1 + superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx | 4 +--- 7 files changed, 7 insertions(+), 17 deletions(-) diff --git a/superset-frontend/src/components/Select/Select.tsx b/superset-frontend/src/components/Select/Select.tsx index cc351ca739500..46b96666bc433 100644 --- a/superset-frontend/src/components/Select/Select.tsx +++ b/superset-frontend/src/components/Select/Select.tsx @@ -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, ) => { @@ -684,6 +684,4 @@ const Select = ({ ); }; -Select.propertyComparator = propertyComparator; - export default Select; diff --git a/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx b/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx index 667e4cf33eaed..3a8aef03727c9 100644 --- a/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx +++ b/superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx @@ -17,7 +17,7 @@ * 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'; @@ -25,8 +25,6 @@ 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')], diff --git a/superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx b/superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx index 191b3a769dd88..252feff4ee314 100644 --- a/superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx +++ b/superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx @@ -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 { @@ -28,8 +28,6 @@ import { MULTIPLE_VALUE_COMPARATORS, } from './types'; -const { propertyComparator } = Select; - const FullWidthInputNumber = styled(InputNumber)` width: 100%; `; diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx index e8d389d7e7430..e5324a926bdd3 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx @@ -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'; @@ -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'; diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx index dde6524ad6d29..a26d7ca765574 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx @@ -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, @@ -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) { diff --git a/superset-frontend/src/explore/components/controls/SelectAsyncControl/SelectAsyncControl.test.tsx b/superset-frontend/src/explore/components/controls/SelectAsyncControl/SelectAsyncControl.test.tsx index 0b0b3034a6395..bc78434850818 100644 --- a/superset-frontend/src/explore/components/controls/SelectAsyncControl/SelectAsyncControl.test.tsx +++ b/superset-frontend/src/explore/components/controls/SelectAsyncControl/SelectAsyncControl.test.tsx @@ -44,6 +44,7 @@ jest.mock('src/components/Select/Select', () => ({ ), + propertyComparator: jest.fn(), })); fetchMock.get(datasetsOwnersEndpoint, { diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx index 409d89f56d7ec..c8c4df66a5dd3 100644 --- a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx +++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx @@ -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'; @@ -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',