Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

filter dropdown

kruzhambus8bd9e70c7e2b
diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsx
index 33d4da796..28054588d 100644
--- a/src/pages/Project/View/ViewProject.tsx
+++ b/src/pages/Project/View/ViewProject.tsx
@@ -42,7 +42,8 @@ import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
import {
tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,
timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, PROJECT_TABS,
- TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER, isSelfhosted, tbPeriodPairsCompare, PERIOD_PAIRS_COMPARE, periodToCompareDate,
+ TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER, isSelfhosted, tbPeriodPairsCompare,
+ PERIOD_PAIRS_COMPARE, periodToCompareDate, filtersPeriodPairs,
} from 'redux/constants'
import { IUser } from 'redux/models/IUser'
import { IProject, ILiveStats } from 'redux/models/IProject'
@@ -1605,7 +1606,11 @@ const ViewProject = ({
</span>
</div>
<Dropdown
- items={periodPairs}
+ items={isActiveCompare ? _filter(periodPairs, (el) => {
+ return _includes(filtersPeriodPairs, el.period)
+ }) : _includes(filtersPeriodPairs, period) ? periodPairs : _filter(periodPairs, (el) => {
+ return el.period !== PERIOD_PAIRS_COMPARE.COMPARE
+ })}
title={activePeriod?.label}
labelExtractor={(pair) => pair.dropdownLabel || pair.label}
keyExtractor={(pair) => pair.label}
diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.ts
index 6ecaa3aab..962bd1c88 100644
--- a/src/redux/constants/index.ts
+++ b/src/redux/constants/index.ts
@@ -72,6 +72,8 @@ export const tbPeriodPairs = (t: Function, tbs?: string[] | null, dates?: Date[]
tbs: tbs || ['custom'],
}]
+export const filtersPeriodPairs = ['1d', '7d', '4w', '3M', '12M', 'custom', 'compare']
+
export const tbPeriodPairsCompare = (t: Function, dates?: Date[]): {
label: string
period: string