umami/components/metrics/PagesTable.js

35 lines
929 B
JavaScript
Raw Normal View History

2020-08-23 07:01:14 +02:00
import React, { useState } from 'react';
import MetricsTable from './MetricsTable';
import { urlFilter } from 'lib/filters';
2020-08-23 07:01:14 +02:00
import ButtonGroup from '../common/ButtonGroup';
2020-08-31 23:11:30 +02:00
export default function PagesTable({ websiteId, websiteDomain, limit, onExpand }) {
2020-08-23 07:01:14 +02:00
const [filter, setFilter] = useState('Combined');
return (
<MetricsTable
title="Pages"
type="url"
metric="Views"
2020-08-23 07:01:14 +02:00
headerComponent={limit ? null : <FilterButtons selected={filter} onClick={setFilter} />}
websiteId={websiteId}
limit={limit}
dataFilter={urlFilter}
2020-08-23 07:01:14 +02:00
filterOptions={{ domain: websiteDomain, raw: filter === 'Raw' }}
2020-08-25 08:49:14 +02:00
renderLabel={({ x }) => decodeURI(x)}
onExpand={onExpand}
/>
);
}
2020-08-23 07:01:14 +02:00
const FilterButtons = ({ selected, onClick }) => {
return (
<ButtonGroup
size="xsmall"
items={['Combined', 'Raw']}
selectedItem={selected}
onClick={onClick}
/>
);
};