Add DialogTrigger to overflow menus
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run

This commit is contained in:
Francis Cao 2025-10-29 12:38:52 -07:00
parent 72fba187db
commit f073fb1996
5 changed files with 26 additions and 24 deletions

View file

@ -1,23 +1,27 @@
'use client'; 'use client';
import { useState } from 'react';
import { Button, Column, Box, DialogTrigger, Popover, Dialog, IconLabel } from '@umami/react-zen';
import { useDateRange, useMessages } from '@/components/hooks';
import { ListCheck } from '@/components/icons';
import { Panel } from '@/components/common/Panel';
import { Breakdown } from './Breakdown';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { FieldSelectForm } from '@/app/(main)/websites/[websiteId]/(reports)/breakdown/FieldSelectForm'; import { FieldSelectForm } from '@/app/(main)/websites/[websiteId]/(reports)/breakdown/FieldSelectForm';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { Panel } from '@/components/common/Panel';
import { useDateRange, useMessages, useMobile } from '@/components/hooks';
import { ListCheck } from '@/components/icons';
import { DialogButton } from '@/components/input/DialogButton';
import { Column, Row } from '@umami/react-zen';
import { useState } from 'react';
import { Breakdown } from './Breakdown';
export function BreakdownPage({ websiteId }: { websiteId: string }) { export function BreakdownPage({ websiteId }: { websiteId: string }) {
const { const {
dateRange: { startDate, endDate }, dateRange: { startDate, endDate },
} = useDateRange(); } = useDateRange();
const [fields, setFields] = useState(['path']); const [fields, setFields] = useState(['path']);
const { isMobile } = useMobile();
return ( return (
<Column gap> <Column gap>
<WebsiteControls websiteId={websiteId} /> <WebsiteControls websiteId={websiteId} />
<Row alignItems="center" justifyContent={isMobile ? 'flex-end' : 'flex-start'}>
<FieldsButton value={fields} onChange={setFields} /> <FieldsButton value={fields} onChange={setFields} />
</Row>
<Panel height="900px" overflow="auto" allowFullscreen> <Panel height="900px" overflow="auto" allowFullscreen>
<Breakdown <Breakdown
websiteId={websiteId} websiteId={websiteId}
@ -34,19 +38,15 @@ const FieldsButton = ({ value, onChange }) => {
const { formatMessage, labels } = useMessages(); const { formatMessage, labels } = useMessages();
return ( return (
<Box> <DialogButton
<DialogTrigger> icon={<ListCheck />}
<Button> label={formatMessage(labels.fields)}
<IconLabel icon={<ListCheck />}>{formatMessage(labels.fields)}</IconLabel> width="800px"
</Button> minHeight="300px"
<Popover> >
<Dialog title={formatMessage(labels.fields)} style={{ width: 400 }}> {({ close }) => {
{({ close }) => ( return <FieldSelectForm selectedFields={value} onChange={onChange} onClose={close} />;
<FieldSelectForm selectedFields={value} onChange={onChange} onClose={close} /> }}
)} </DialogButton>
</Dialog>
</Popover>
</DialogTrigger>
</Box>
); );
}; };

View file

@ -12,7 +12,7 @@ export function CohortAddButton({ websiteId }: { websiteId: string }) {
label={formatMessage(labels.cohort)} label={formatMessage(labels.cohort)}
variant="primary" variant="primary"
width="800px" width="800px"
minHeight="300px" height="calc(100dvh - 40px)"
> >
{({ close }) => { {({ close }) => {
return <CohortEditForm websiteId={websiteId} onClose={close} />; return <CohortEditForm websiteId={websiteId} onClose={close} />;

View file

@ -21,7 +21,7 @@ export function CohortEditButton({
variant="quiet" variant="quiet"
title={formatMessage(labels.cohort)} title={formatMessage(labels.cohort)}
width="800px" width="800px"
minHeight="300px" height="calc(100dvh - 40px)"
> >
{({ close }) => { {({ close }) => {
return ( return (

View file

@ -12,6 +12,7 @@ export function SegmentAddButton({ websiteId }: { websiteId: string }) {
label={formatMessage(labels.segment)} label={formatMessage(labels.segment)}
variant="primary" variant="primary"
width="800px" width="800px"
height="calc(100dvh - 40px)"
> >
{({ close }) => { {({ close }) => {
return <SegmentEditForm websiteId={websiteId} onClose={close} />; return <SegmentEditForm websiteId={websiteId} onClose={close} />;

View file

@ -21,6 +21,7 @@ export function SegmentEditButton({
title={formatMessage(labels.segment)} title={formatMessage(labels.segment)}
variant="quiet" variant="quiet"
width="800px" width="800px"
height="calc(100dvh - 40px)"
> >
{({ close }) => { {({ close }) => {
return ( return (