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!

Display applied filters on the NoEvents screen

Blue Mousee534bf25adce
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index 16ae91455..cf51c4ed8 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -2832,16 +2832,6 @@ const ViewProject = () => {
}
}
- const resetFilters = () => {
- cleanURLFilters()
-
- setFilters([])
- setFiltersPerf([])
- setFiltersSessions([])
- setFiltersErrors([])
- setFiltersSubError([])
- }
-
const exportTypes = [
{
label: t('project.asCSV'),
@@ -3865,7 +3855,12 @@ const ViewProject = () => {
/>
{(sessionsLoading === null || sessionsLoading) && _isEmpty(sessions) && <Loader />}
{typeof sessionsLoading === 'boolean' && !sessionsLoading && _isEmpty(sessions) && (
- <NoEvents filters={filters} resetFilters={resetFilters} />
+ <NoEvents
+ filters={filters}
+ filterHandler={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ resetActiveTabFilters={resetActiveTabFilters}
+ />
)}
<Sessions
sessions={sessions}
@@ -3936,7 +3931,12 @@ const ViewProject = () => {
/>
{(errorsLoading === null || errorsLoading) && _isEmpty(errors) && <Loader />}
{typeof errorsLoading === 'boolean' && !errorsLoading && _isEmpty(errors) && (
- <NoEvents filters={filtersErrors} resetFilters={resetFilters} />
+ <NoEvents
+ filters={filtersErrors}
+ filterHandler={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ resetActiveTabFilters={resetActiveTabFilters}
+ />
)}
<Errors
errors={errors}
@@ -4222,10 +4222,20 @@ const ViewProject = () => {
<Loader />
)}
{isPanelsDataEmpty && activeTab === PROJECT_TABS.traffic && (
- <NoEvents filters={filters} resetFilters={resetFilters} />
+ <NoEvents
+ filters={filters}
+ filterHandler={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ resetActiveTabFilters={resetActiveTabFilters}
+ />
)}
{isPanelsDataEmptyPerf && activeTab === PROJECT_TABS.performance && (
- <NoEvents filters={filtersPerf} resetFilters={resetFilters} />
+ <NoEvents
+ filters={filtersPerf}
+ filterHandler={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ resetActiveTabFilters={resetActiveTabFilters}
+ />
)}
{activeTab === PROJECT_TABS.traffic && (
<div className={cx('pt-2', { hidden: isPanelsDataEmpty || analyticsLoading })}>
diff --git a/web/app/pages/Project/View/components/NoEvents.tsx b/web/app/pages/Project/View/components/NoEvents.tsx
index 71afe2af9..f3485f73c 100644
--- a/web/app/pages/Project/View/components/NoEvents.tsx
+++ b/web/app/pages/Project/View/components/NoEvents.tsx
@@ -2,31 +2,49 @@ import React, { memo } from 'react'
import { useTranslation } from 'react-i18next'
import _isEmpty from 'lodash/isEmpty'
-import Button from '~/ui/Button'
import { Filter } from '../interfaces/traffic'
+import Filters from './Filters'
+import { typeNameMapping } from '../ViewProject.helpers'
interface NoEventsProps {
filters: Filter[]
- resetFilters: () => void
+ filterHandler: (column: string, filter: any) => void
+ onChangeExclusive: (column: string, filter: any, isExclusive: boolean) => void
+ resetActiveTabFilters: () => void
}
-const NoEvents = ({ filters, resetFilters }: NoEventsProps) => {
+const NoEvents = ({ filters, filterHandler, onChangeExclusive, resetActiveTabFilters }: NoEventsProps) => {
const { t } = useTranslation('common')
+ const tnMapping = typeNameMapping(t)
+
+ if (_isEmpty(filters)) {
+ return (
+ <div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>
+ <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>
+ <h2 className='my-3 text-center text-4xl leading-tight'>{t('project.noEvTitle')}</h2>
+ <h3 className='mb-8 text-center text-2xl leading-snug'>{t('project.noEvContent')}</h3>
+ </div>
+ </div>
+ )
+ }
return (
- <div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>
- <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>
- <h2 className='my-3 text-center text-4xl leading-tight'>{t('project.noEvTitle')}</h2>
- <h2 className='mb-8 text-center text-2xl leading-snug'>{t('project.noEvContent')}</h2>
- {!_isEmpty(filters) && (
- <div className='!mx-auto !flex'>
- <Button onClick={resetFilters} className='!mx-auto !flex' primary giant>
- {t('project.resetFilters')}
- </Button>
- </div>
- )}
+ <>
+ <div className='mt-4'>
+ <Filters
+ onRemoveFilter={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ tnMapping={tnMapping}
+ resetFilters={resetActiveTabFilters}
+ />
+ </div>
+ <div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>
+ <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>
+ <h2 className='my-3 text-center text-4xl leading-tight'>{t('project.noEvTitle')}</h2>
+ <h3 className='mb-8 text-center text-2xl leading-snug'>{t('project.noEventsFiltersDesc')}</h3>
+ </div>
</div>
- </div>
+ </>
)
}
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 8600d7d87..3aa92cd8c 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -941,6 +941,7 @@
},
"trendlineTotal": "Pageviews trendline",
"noEvContent": "No events have been recorded for the specified period, please try a different period.",
+ "noEventsFiltersDesc": "No events have been recorded for the specified period or applied filters, please try a different period or change the filters applied.",
"noCaptchaEv": "No events have been captured for the specified timeframe.\nIf you haven't set up CAPTCHA yet, you can check out our <url>Docs</url> to easily integrate it into your app.",
"mapping": {
"cc": "Country",