From 4119e80a9a0fa76841d2ddfeb31c03e4173bc4ae Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Sun, 11 Oct 2020 01:33:26 -0700 Subject: [PATCH] Update table components. --- components/metrics/BrowsersTable.js | 4 ++-- components/metrics/CountriesTable.js | 6 +++--- components/metrics/DataTable.js | 18 +++++++++--------- components/metrics/DevicesTable.js | 4 ++-- components/metrics/EventsTable.js | 5 ++--- components/metrics/MetricsTable.js | 8 +++++--- components/metrics/PagesTable.js | 4 ++-- components/metrics/ReferrersTable.js | 4 ++-- components/pages/RealtimeDashboard.js | 18 ++++++++---------- components/pages/WebsiteDetails.js | 4 ++-- pages/api/website/[id]/metrics.js | 2 +- 11 files changed, 38 insertions(+), 39 deletions(-) diff --git a/components/metrics/BrowsersTable.js b/components/metrics/BrowsersTable.js index 97f9bfbd..3481449c 100644 --- a/components/metrics/BrowsersTable.js +++ b/components/metrics/BrowsersTable.js @@ -3,15 +3,15 @@ import { FormattedMessage } from 'react-intl'; import MetricsTable from './MetricsTable'; import { browserFilter } from 'lib/filters'; -export default function BrowsersTable({ websiteId, token, limit }) { +export default function BrowsersTable({ websiteId, token, ...props }) { return ( } type="browser" metric={} websiteId={websiteId} token={token} - limit={limit} dataFilter={browserFilter} /> ); diff --git a/components/metrics/CountriesTable.js b/components/metrics/CountriesTable.js index d562b464..5b44bd23 100644 --- a/components/metrics/CountriesTable.js +++ b/components/metrics/CountriesTable.js @@ -5,7 +5,7 @@ import { FormattedMessage } from 'react-intl'; import useCountryNames from 'hooks/useCountryNames'; import useLocale from 'hooks/useLocale'; -export default function CountriesTable({ websiteId, token, limit, onDataLoad = () => {} }) { +export default function CountriesTable({ websiteId, token, onDataLoad, ...props }) { const [locale] = useLocale(); const countryNames = useCountryNames(locale); @@ -15,13 +15,13 @@ export default function CountriesTable({ websiteId, token, limit, onDataLoad = ( return ( } type="country" metric={} websiteId={websiteId} token={token} - limit={limit} - onDataLoad={data => onDataLoad(percentFilter(data))} + onDataLoad={data => onDataLoad?.(percentFilter(data))} renderLabel={renderLabel} /> ); diff --git a/components/metrics/DataTable.js b/components/metrics/DataTable.js index 9e12d887..70eae89f 100644 --- a/components/metrics/DataTable.js +++ b/components/metrics/DataTable.js @@ -11,10 +11,10 @@ export default function DataTable({ title, metric, className, - limit, renderLabel, height = 400, animate = true, + virtualize = false, }) { const [format, setFormat] = useState(true); const formatFunc = format ? formatLongNumber : formatNumber; @@ -30,7 +30,7 @@ export default function DataTable({ label={renderLabel ? renderLabel(row) : label} value={value} percent={percent} - animate={animate} + animate={animate && !virtualize} format={formatFunc} onClick={handleSetFormat} /> @@ -51,13 +51,13 @@ export default function DataTable({
{data?.length === 0 && } - {limit - ? data.map(row => getRow(row)) - : data.length > 0 && ( - - {Row} - - )} + {virtualize && data.length > 0 ? ( + + {Row} + + ) : ( + data.map(row => getRow(row)) + )}
); diff --git a/components/metrics/DevicesTable.js b/components/metrics/DevicesTable.js index 7d87d1c1..e71355db 100644 --- a/components/metrics/DevicesTable.js +++ b/components/metrics/DevicesTable.js @@ -4,15 +4,15 @@ import { deviceFilter } from 'lib/filters'; import { FormattedMessage } from 'react-intl'; import { getDeviceMessage } from 'components/messages'; -export default function DevicesTable({ websiteId, token, limit }) { +export default function DevicesTable({ websiteId, token, ...props }) { return ( } type="device" metric={} websiteId={websiteId} token={token} - limit={limit} dataFilter={deviceFilter} renderLabel={({ x }) => getDeviceMessage(x)} /> diff --git a/components/metrics/EventsTable.js b/components/metrics/EventsTable.js index 43b52c4d..73df5028 100644 --- a/components/metrics/EventsTable.js +++ b/components/metrics/EventsTable.js @@ -3,17 +3,16 @@ import { FormattedMessage } from 'react-intl'; import MetricsTable from './MetricsTable'; import Tag from 'components/common/Tag'; -export default function EventsTable({ websiteId, token, limit, onDataLoad }) { +export default function EventsTable({ websiteId, token, ...props }) { return ( } type="event" metric={} websiteId={websiteId} token={token} - limit={limit} renderLabel={({ x }) =>