From da040fc024fa432f66c3511c548946a4a205dffa Mon Sep 17 00:00:00 2001 From: Paolo D'Amico Date: Thu, 6 May 2021 18:38:29 -0700 Subject: [PATCH] Fix date range component in insights (#4248) --- .../{DateFilter => InsightDateFilter}/index.scss | 0 .../{DateFilter => InsightDateFilter}/index.tsx | 12 ++++++------ .../insightDateFilterLogic.ts} | 4 ++-- .../insights/InsightTabs/InsightDisplayConfig.tsx | 6 +++--- frontend/src/scenes/insights/insightCommandLogic.ts | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) rename frontend/src/scenes/insights/{DateFilter => InsightDateFilter}/index.scss (100%) rename frontend/src/scenes/insights/{DateFilter => InsightDateFilter}/index.tsx (62%) rename frontend/src/scenes/insights/{DateFilter/dateFilterLogic.ts => InsightDateFilter/insightDateFilterLogic.ts} (93%) diff --git a/frontend/src/scenes/insights/DateFilter/index.scss b/frontend/src/scenes/insights/InsightDateFilter/index.scss similarity index 100% rename from frontend/src/scenes/insights/DateFilter/index.scss rename to frontend/src/scenes/insights/InsightDateFilter/index.scss diff --git a/frontend/src/scenes/insights/DateFilter/index.tsx b/frontend/src/scenes/insights/InsightDateFilter/index.tsx similarity index 62% rename from frontend/src/scenes/insights/DateFilter/index.tsx rename to frontend/src/scenes/insights/InsightDateFilter/index.tsx index 9d46be0b6b8..aef00840f51 100644 --- a/frontend/src/scenes/insights/DateFilter/index.tsx +++ b/frontend/src/scenes/insights/InsightDateFilter/index.tsx @@ -1,19 +1,19 @@ import React from 'react' import { useValues, useActions } from 'kea' -import { dateFilterLogic } from './dateFilterLogic' -import { DateFilterProps, DateFilter as DateFilterComponent } from 'lib/components/DateFilter/DateFilter' +import { insightDateFilterLogic } from './insightDateFilterLogic' +import { DateFilterProps, DateFilter } from 'lib/components/DateFilter/DateFilter' import './index.scss' -export function DateFilter(props: DateFilterProps): JSX.Element { +export function InsightDateFilter(props: DateFilterProps): JSX.Element { const { dates: { dateFrom, dateTo }, highlightDateChange, - } = useValues(dateFilterLogic) - const { setDates } = useActions(dateFilterLogic) + } = useValues(insightDateFilterLogic) + const { setDates } = useActions(insightDateFilterLogic) return ( - >({ +export const insightDateFilterLogic = kea>({ actions: () => ({ setDates: (dateFrom: string | Dayjs | undefined, dateTo: string | Dayjs | undefined) => ({ dateFrom, diff --git a/frontend/src/scenes/insights/InsightTabs/InsightDisplayConfig.tsx b/frontend/src/scenes/insights/InsightTabs/InsightDisplayConfig.tsx index 36606be386f..6428adbe59e 100644 --- a/frontend/src/scenes/insights/InsightTabs/InsightDisplayConfig.tsx +++ b/frontend/src/scenes/insights/InsightTabs/InsightDisplayConfig.tsx @@ -1,7 +1,6 @@ import { useValues } from 'kea' import { ChartFilter } from 'lib/components/ChartFilter' import { CompareFilter } from 'lib/components/CompareFilter/CompareFilter' -import { DateFilter } from 'lib/components/DateFilter/DateFilter' import { IntervalFilter } from 'lib/components/IntervalFilter' import { SaveToDashboard } from 'lib/components/SaveToDashboard/SaveToDashboard' import { TZIndicator } from 'lib/components/TimezoneAware' @@ -11,6 +10,7 @@ import React from 'react' import { DisplayType, FilterType } from '~/types' import { ViewType } from '../insightLogic' import { CalendarOutlined } from '@ant-design/icons' +import { InsightDateFilter } from '../InsightDateFilter' interface InsightDisplayConfigProps { clearAnnotationsToCreate: () => void @@ -114,7 +114,7 @@ function DefaultInsightDisplayConfig({ )} {showDateFilter[activeView] && ( - + )} {showComparePrevious[activeView] && } @@ -161,7 +161,7 @@ function HorizontalDefaultInsightDisplayConfig({ {showIntervalFilter(activeView, allFilters) && } {showDateFilter[activeView] && ( <> - ({ - connect: [commandPaletteLogic, compareFilterLogic, dateFilterLogic], + connect: [commandPaletteLogic, compareFilterLogic, insightDateFilterLogic], events: () => ({ afterMount: () => { const funnelCommands: Command[] = [ @@ -27,7 +27,7 @@ export const insightCommandLogic = kea({ icon: RiseOutlined, display: `Set Time Range to ${key}`, executor: () => { - dateFilterLogic.actions.setDates(value[0], value[1]) + insightDateFilterLogic.actions.setDates(value[0], value[1]) }, })), ],