From 5cc4f3c4b99fa9388d7f37f08c572533c55ae686 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Mon, 19 Jul 2021 08:04:07 +0200 Subject: [PATCH] chore: Select component refactoring - DateFilterControl - Iteration 5 (#15571) * Transition to Antd for DateFilterLabel * Enhance styles * Fix test * Update superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.test.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> --- .../DateFilterControl/DateFilterLabel.tsx | 27 +++++++------ .../components/CustomFrame.test.tsx | 8 ++-- .../components/CustomFrame.tsx | 39 +++++++------------ 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx index efc632300a..daa3be910f 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx @@ -40,13 +40,13 @@ import Label 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/Select'; +import { Select } from 'src/components'; import { Tooltip } from 'src/components/Tooltip'; import { DEFAULT_TIME_RANGE } from 'src/explore/constants'; import { useDebouncedEffect } from 'src/explore/exploreUtils'; import { SLOW_DEBOUNCE } from 'src/constants'; import { testWithId } from 'src/utils/testUtils'; -import { SelectOptionType, FrameType } from './types'; +import { FrameType } from './types'; import { CommonFrame, @@ -95,6 +95,9 @@ const fetchTimeRange = async ( }; const StyledPopover = styled(Popover)``; +const StyledRangeType = styled(Select)` + width: 272px; +`; const ContentStyleWrapper = styled.div` .ant-row { @@ -105,10 +108,6 @@ const ContentStyleWrapper = styled.div` width: 100%; } - .frame-dropdown { - width: 272px; - } - .ant-picker { padding: 4px 17px 4px; border-radius: 4px; @@ -274,23 +273,23 @@ export default function DateFilterLabel(props: DateFilterControlProps) { } }; - function onChangeFrame(option: SelectOptionType) { - if (option.value === 'No filter') { + function onChangeFrame(value: string) { + if (value === 'No filter') { setTimeRangeValue('No filter'); } - setFrame(option.value as FrameType); + setFrame(value as FrameType); } const theme = useTheme(); - const overlayConetent = ( + const overlayContent = (
{t('RANGE TYPE')}
- option.value === sinceMode, - )} - onChange={(option: SelectOptionType) => - onChange('sinceMode', option.value) - } + value={sinceMode} + onChange={(value: string) => onChange('sinceMode', value)} /> {sinceMode === 'specific' && ( @@ -155,13 +151,10 @@ export function CustomFrame(props: FrameComponentProps) { option.value === untilMode, - )} - onChange={(option: SelectOptionType) => - onChange('untilMode', option.value) - } + value={untilMode} + onChange={(value: string) => onChange('untilMode', value)} /> {untilMode === 'specific' && ( @@ -212,13 +202,10 @@ export function CustomFrame(props: FrameComponentProps) {