2022-04-10 12:51:43 +02:00
|
|
|
import FilterLink from 'components/common/FilterLink';
|
2023-03-31 14:55:28 +02:00
|
|
|
import FilterButtons from 'components/common/FilterButtons';
|
2020-09-06 02:27:01 +02:00
|
|
|
import MetricsTable from './MetricsTable';
|
2023-03-22 22:05:55 +01:00
|
|
|
import useMessages from 'hooks/useMessages';
|
2023-03-31 14:55:28 +02:00
|
|
|
import usePageQuery from 'hooks/usePageQuery';
|
2020-08-23 04:05:07 +02:00
|
|
|
|
2023-03-31 14:55:28 +02:00
|
|
|
export default function PagesTable({ websiteId, showFilters, ...props }) {
|
|
|
|
const {
|
|
|
|
router,
|
|
|
|
resolveUrl,
|
2023-04-01 05:03:28 +02:00
|
|
|
query: { view = 'url' },
|
2023-03-31 14:55:28 +02:00
|
|
|
} = usePageQuery();
|
2023-03-22 22:05:55 +01:00
|
|
|
const { formatMessage, labels } = useMessages();
|
2020-09-06 02:27:01 +02:00
|
|
|
|
2023-03-31 14:55:28 +02:00
|
|
|
const handleSelect = key => {
|
|
|
|
router.push(resolveUrl({ view: key }), null, { shallow: true });
|
|
|
|
};
|
|
|
|
|
|
|
|
const buttons = [
|
|
|
|
{
|
|
|
|
label: formatMessage(labels.url),
|
|
|
|
key: 'url',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: formatMessage(labels.title),
|
|
|
|
key: 'title',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const renderLink = ({ x }) => {
|
|
|
|
return <FilterLink id={view} value={x || `(${formatMessage(labels.none)})`} />;
|
2020-09-26 07:31:18 +02:00
|
|
|
};
|
|
|
|
|
2020-08-23 04:05:07 +02:00
|
|
|
return (
|
2020-09-22 06:34:55 +02:00
|
|
|
<>
|
2023-03-31 14:55:28 +02:00
|
|
|
{showFilters && <FilterButtons items={buttons} selectedKey={view} onSelect={handleSelect} />}
|
2020-09-22 06:34:55 +02:00
|
|
|
<MetricsTable
|
2023-04-01 06:31:58 +02:00
|
|
|
{...props}
|
2023-02-10 12:26:57 +01:00
|
|
|
title={formatMessage(labels.pages)}
|
2023-03-31 14:55:28 +02:00
|
|
|
type={view}
|
2023-02-10 12:26:57 +01:00
|
|
|
metric={formatMessage(labels.views)}
|
2020-09-22 06:34:55 +02:00
|
|
|
websiteId={websiteId}
|
2020-09-26 07:31:18 +02:00
|
|
|
renderLabel={renderLink}
|
2020-09-22 06:34:55 +02:00
|
|
|
/>
|
|
|
|
</>
|
2020-08-23 04:05:07 +02:00
|
|
|
);
|
|
|
|
}
|