Merge branch 'dev' into analytics

This commit is contained in:
Mike Cao 2023-12-13 12:31:46 -08:00
commit 4a1a51fb8b
6 changed files with 31 additions and 15 deletions

View file

@ -33,8 +33,8 @@ export default function WebsiteDetails({ websiteId }: { websiteId: string }) {
{!website && <Loading icon="dots" style={{ minHeight: 300 }} />} {!website && <Loading icon="dots" style={{ minHeight: 300 }} />}
{website && ( {website && (
<> <>
{!view && <WebsiteTableView websiteId={websiteId} />} {!view && <WebsiteTableView websiteId={websiteId} domainName={website.domain} />}
{view && <WebsiteExpandedView websiteId={websiteId} />} {view && <WebsiteExpandedView websiteId={websiteId} domainName={website.domain} />}
</> </>
)} )}
</> </>

View file

@ -35,10 +35,10 @@ const views = {
export default function WebsiteExpandedView({ export default function WebsiteExpandedView({
websiteId, websiteId,
websiteDomain, domainName,
}: { }: {
websiteId: string; websiteId: string;
websiteDomain?: string; domainName?: string;
}) { }) {
const { formatMessage, labels } = useMessages(); const { formatMessage, labels } = useMessages();
const { const {
@ -143,7 +143,7 @@ export default function WebsiteExpandedView({
<div className={styles.content}> <div className={styles.content}>
<DetailsComponent <DetailsComponent
websiteId={websiteId} websiteId={websiteId}
websiteDomain={websiteDomain} domainName={domainName}
animate={false} animate={false}
virtualize={true} virtualize={true}
itemCount={25} itemCount={25}

View file

@ -10,10 +10,17 @@ import CountriesTable from 'components/metrics/CountriesTable';
import EventsTable from 'components/metrics/EventsTable'; import EventsTable from 'components/metrics/EventsTable';
import EventsChart from 'components/metrics/EventsChart'; import EventsChart from 'components/metrics/EventsChart';
export default function WebsiteTableView({ websiteId }: { websiteId: string }) { export default function WebsiteTableView({
websiteId,
domainName,
}: {
websiteId: string;
domainName: string;
}) {
const [countryData, setCountryData] = useState(); const [countryData, setCountryData] = useState();
const tableProps = { const tableProps = {
websiteId, websiteId,
domainName,
limit: 10, limit: 10,
}; };

View file

@ -19,11 +19,11 @@ export function FilterTags({ params }) {
} }
function handleCloseFilter(param?: string) { function handleCloseFilter(param?: string) {
if (!param) { router.push(makeUrl({ [param]: undefined }));
router.push(makeUrl({ view }, true)); }
} else {
router.push(makeUrl({ [param]: undefined })); function handleResetFilter() {
} router.push(makeUrl({ view }, true));
} }
return ( return (
@ -44,7 +44,7 @@ export function FilterTags({ params }) {
</div> </div>
); );
})} })}
<Button size="sm" variant="quiet" onClick={handleCloseFilter}> <Button size="sm" variant="quiet" onClick={handleResetFilter}>
<Icon> <Icon>
<Icons.Close /> <Icons.Close />
</Icon> </Icon>

View file

@ -17,6 +17,7 @@ import styles from './MetricsTable.module.css';
export interface MetricsTableProps extends ListTableProps { export interface MetricsTableProps extends ListTableProps {
websiteId: string; websiteId: string;
domainName: string;
type?: string; type?: string;
className?: string; className?: string;
dataFilter?: (data: any) => any; dataFilter?: (data: any) => any;

View file

@ -9,7 +9,7 @@ export interface PagesTableProps extends MetricsTableProps {
allowFilter?: boolean; allowFilter?: boolean;
} }
export function PagesTable({ allowFilter, ...props }: PagesTableProps) { export function PagesTable({ allowFilter, domainName, ...props }: PagesTableProps) {
const { const {
router, router,
makeUrl, makeUrl,
@ -17,7 +17,7 @@ export function PagesTable({ allowFilter, ...props }: PagesTableProps) {
} = useNavigation(); } = useNavigation();
const { formatMessage, labels } = useMessages(); const { formatMessage, labels } = useMessages();
const handleSelect = key => { const handleSelect = (key: any) => {
router.push(makeUrl({ view: key }), { scroll: true }); router.push(makeUrl({ view: key }), { scroll: true });
}; };
@ -33,12 +33,20 @@ export function PagesTable({ allowFilter, ...props }: PagesTableProps) {
]; ];
const renderLink = ({ x }) => { const renderLink = ({ x }) => {
return <FilterLink id={view} value={x} label={!x && formatMessage(labels.none)} />; return (
<FilterLink
id={view}
value={x}
label={!x && formatMessage(labels.none)}
externalUrl={`${domainName.startsWith('http') ? domainName : `https://${domainName}`}${x}`}
/>
);
}; };
return ( return (
<MetricsTable <MetricsTable
{...props} {...props}
domainName={domainName}
title={formatMessage(labels.pages)} title={formatMessage(labels.pages)}
type={view} type={view}
metric={formatMessage(labels.views)} metric={formatMessage(labels.views)}