From 69620d03ab8c48de0e615adecc56083c2b811c8f Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Sat, 18 Dec 2021 12:09:32 +0800 Subject: [PATCH 1/3] Fix incorrect time range display --- .../controls/DateFilterControl/DateFilterLabel.tsx | 4 ++-- superset-frontend/src/explore/constants.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx index 71f84a8459ff1..b4b921a6934e6 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx @@ -42,7 +42,7 @@ import { Divider } from 'src/common/components'; import Icons from 'src/components/Icons'; import { Select } from 'src/components'; import { Tooltip } from 'src/components/Tooltip'; -import { DEFAULT_TIME_RANGE } from 'src/explore/constants'; +import {DEFAULT_TIME_RANGE, DEFAULT_TIME_RANGE_ENDPOINTS} from 'src/explore/constants'; import { useDebouncedEffect } from 'src/explore/exploreUtils'; import { SLOW_DEBOUNCE } from 'src/constants'; import { testWithId } from 'src/utils/testUtils'; @@ -181,7 +181,7 @@ export const getDateFilterControlTestId = testWithId( ); export default function DateFilterLabel(props: DateFilterControlProps) { - const { value = DEFAULT_TIME_RANGE, endpoints, onChange, type } = props; + const { value = DEFAULT_TIME_RANGE, endpoints = DEFAULT_TIME_RANGE_ENDPOINTS, onChange, type } = props; const [actualTimeRange, setActualTimeRange] = useState(value); const [show, setShow] = useState(false); diff --git a/superset-frontend/src/explore/constants.ts b/superset-frontend/src/explore/constants.ts index c3b31f1de568a..2f20d23110817 100644 --- a/superset-frontend/src/explore/constants.ts +++ b/superset-frontend/src/explore/constants.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { t } from '@superset-ui/core'; +import {t, TimeRangeEndpoints} from '@superset-ui/core'; export const AGGREGATES = { AVG: 'AVG', @@ -136,4 +136,9 @@ export const TIME_FILTER_MAP = { // TODO: make this configurable per Superset installation export const DEFAULT_TIME_RANGE = 'No filter'; +// Default time range endpoints [start, end) +export const DEFAULT_TIME_RANGE_ENDPOINTS: TimeRangeEndpoints = [ + 'inclusive', + 'exclusive', +]; export const NO_TIME_RANGE = 'No filter'; From 6ec56f8e6872a97dd4319bc63d733ccc92733732 Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Sun, 19 Dec 2021 13:10:55 +0800 Subject: [PATCH 2/3] Fix linting --- .../controls/DateFilterControl/DateFilterLabel.tsx | 12 ++++++++++-- superset-frontend/src/explore/constants.ts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx index b4b921a6934e6..2066636bfb047 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx @@ -42,7 +42,10 @@ import { Divider } from 'src/common/components'; import Icons from 'src/components/Icons'; import { Select } from 'src/components'; import { Tooltip } from 'src/components/Tooltip'; -import {DEFAULT_TIME_RANGE, DEFAULT_TIME_RANGE_ENDPOINTS} from 'src/explore/constants'; +import { + DEFAULT_TIME_RANGE, + DEFAULT_TIME_RANGE_ENDPOINTS, +} from 'src/explore/constants'; import { useDebouncedEffect } from 'src/explore/exploreUtils'; import { SLOW_DEBOUNCE } from 'src/constants'; import { testWithId } from 'src/utils/testUtils'; @@ -181,7 +184,12 @@ export const getDateFilterControlTestId = testWithId( ); export default function DateFilterLabel(props: DateFilterControlProps) { - const { value = DEFAULT_TIME_RANGE, endpoints = DEFAULT_TIME_RANGE_ENDPOINTS, onChange, type } = props; + const { + value = DEFAULT_TIME_RANGE, + endpoints = DEFAULT_TIME_RANGE_ENDPOINTS, + onChange, + type, + } = props; const [actualTimeRange, setActualTimeRange] = useState(value); const [show, setShow] = useState(false); diff --git a/superset-frontend/src/explore/constants.ts b/superset-frontend/src/explore/constants.ts index 2f20d23110817..f84dad84b581c 100644 --- a/superset-frontend/src/explore/constants.ts +++ b/superset-frontend/src/explore/constants.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import {t, TimeRangeEndpoints} from '@superset-ui/core'; +import { t, TimeRangeEndpoints } from '@superset-ui/core'; export const AGGREGATES = { AVG: 'AVG', From f575477c029254a7f9322f796aeb38a81561bead Mon Sep 17 00:00:00 2001 From: CodeingBoy Date: Wed, 22 Dec 2021 10:14:12 +0800 Subject: [PATCH 3/3] Add SIP reference for DEFAULT_TIME_RANGE_ENDPOINTS --- superset-frontend/src/explore/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/explore/constants.ts b/superset-frontend/src/explore/constants.ts index f84dad84b581c..ca05983f840bb 100644 --- a/superset-frontend/src/explore/constants.ts +++ b/superset-frontend/src/explore/constants.ts @@ -136,7 +136,7 @@ export const TIME_FILTER_MAP = { // TODO: make this configurable per Superset installation export const DEFAULT_TIME_RANGE = 'No filter'; -// Default time range endpoints [start, end) +// Default time range endpoints [start, end), see SIP-15 #6360 for more info export const DEFAULT_TIME_RANGE_ENDPOINTS: TimeRangeEndpoints = [ 'inclusive', 'exclusive',