Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Connect QueryLink to React Router using withRouter
birjolaxewb4f530f4925e
diff --git a/assets/js/dashboard/datepicker.js b/assets/js/dashboard/datepicker.jsindex b53959ba26..b3ee99f3a4 100644--- a/assets/js/dashboard/datepicker.js+++ b/assets/js/dashboard/datepicker.js@@ -118,10 +118,10 @@ class DatePicker extends React.Component {renderArrow(period, prevDate, nextDate) {return (<div className="flex rounded shadow bg-white mr-4 cursor-pointer">- <QueryLink history={this.props.history} query={this.props.query} data={{date: prevDate}} className="flex items-center px-2 border-r border-gray-300">+ <QueryLink query={this.props.query} data={{date: prevDate}} className="flex items-center px-2 border-r border-gray-300"><svg className="feather h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg></QueryLink>- <QueryLink history={this.props.history} query={this.props.query} data={{date: nextDate}} className="flex items-center px-2">+ <QueryLink query={this.props.query} data={{date: nextDate}} className="flex items-center px-2"><svg className="feather h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg></QueryLink></div>@@ -192,7 +192,7 @@ class DatePicker extends React.Component {if (opts.date) { opts.date = formatISO(opts.date) }return (- <QueryLink history={this.props.history} query={this.props.query} data={{period, ...opts}} onClick={this.close.bind(this)} className={boldClass + ' block px-4 py-2 text-sm leading-tight hover:bg-gray-100 hover:text-gray-900'}>+ <QueryLink query={this.props.query} data={{period, ...opts}} onClick={this.close.bind(this)} className={boldClass + ' block px-4 py-2 text-sm leading-tight hover:bg-gray-100 hover:text-gray-900'}>{text}</QueryLink>)diff --git a/assets/js/dashboard/query.js b/assets/js/dashboard/query.jsindex 4ed981cd28..cb9c3cccf3 100644--- a/assets/js/dashboard/query.js+++ b/assets/js/dashboard/query.js@@ -1,5 +1,5 @@import React from 'react'-import { Link } from 'react-router-dom'+import { Link, withRouter } from 'react-router-dom'import {formatDay, formatMonthYYYY, nowForSite, parseUTCDate} from './date'const PERIODS = ['realtime', 'day', 'month', '7d', '30d', '6mo', '12mo', 'custom']@@ -68,7 +68,7 @@ export function navigateToQuery(history, queryFrom, newData) {history.push({ search: generateQueryString(newData) })}-export class QueryLink extends React.Component {+class QueryLink extends React.Component {constructor() {super()this.onClick = this.onClick.bind(this)@@ -85,6 +85,8 @@ export class QueryLink extends React.Component {return <Link {...props} to={generateQueryString(data)} onClick={this.onClick} />}}+const QueryLinkWithRouter = withRouter(QueryLink)+export { QueryLinkWithRouter as QueryLink };export function toHuman(query) {if (query.period === 'day') {