Upgrade react-zen and migrate UI components to its updated APIs

This commit is contained in:
Mike Cao committed 2026-07-30 22:35:20 -07:00
1 parent f054830292
commit 6ac2b9377c
83 files changed
+1337 -506

No files matched your search

+26 -19
View File
@@ -110,27 +110,34 @@ export function SideNav(props: any) {
<Column gap="2">
{links.map(({ id, path, label, icon }) => {
const isSelected = pathname.startsWith(renderUrl(path, false));
const content = (
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={isCollapsed ? '' : label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
</Focusable>
);
return (
<Link key={id} href={renderUrl(path, false)} role="button">
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={isCollapsed ? '' : label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
</Focusable>
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
{isCollapsed ? (
<TooltipTrigger delay={0}>
{content}
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
) : (
content
)}
</Link>
);
})}
+4 -4
View File
@@ -11,19 +11,19 @@ import { WebsiteSelect } from '@/components/input/WebsiteSelect';
export function TopNav() {
const { websiteId, linkId, pixelId, boardId, teamId, router, renderUrl } = useNavigation();
const handleWebsiteChange = (value: string) => {
const handleWebsiteChange = (value: string | number | null) => {
router.push(renderUrl(`/websites/${value}`, false));
};
const handleLinkChange = (value: string) => {
const handleLinkChange = (value: string | number | null) => {
router.push(renderUrl(`/links/${value}`, false));
};
const handlePixelChange = (value: string) => {
const handlePixelChange = (value: string | number | null) => {
router.push(renderUrl(`/pixels/${value}`, false));
};
const handleBoardChange = (value: string) => {
const handleBoardChange = (value: string | number | null) => {
router.push(renderUrl(`/boards/${value}`, false));
};
+10 -7
View File
@@ -1,4 +1,4 @@
import { AlertBanner, Button, Column, Row } from '@umami/react-zen';
import { Alert, AlertTitle, Button, Column, Row } from '@umami/react-zen';
import { usePathname } from 'next/navigation';
import { useCallback, useEffect, useState } from 'react';
import { useMessages } from '@/components/hooks';
@@ -49,12 +49,15 @@ export function UpdateNotice({ user, config }) {
return (
<Column justifyContent="center" alignItems="center" position="fixed" top="10px" width="100%">
<Row width="600px">
<AlertBanner title={t(messages.newVersionAvailable, { version: `v${latest}` })}>
<Button variant="primary" onPress={handleViewClick}>
{t(labels.viewDetails)}
</Button>
<Button onPress={handleDismissClick}>{t(labels.dismiss)}</Button>
</AlertBanner>
<Alert style={{ width: '100%' }}>
<AlertTitle>{t(messages.newVersionAvailable, { version: `v${latest}` })}</AlertTitle>
<Row gap="3" paddingTop="2">
<Button variant="primary" onPress={handleViewClick}>
{t(labels.viewDetails)}
</Button>
<Button onPress={handleDismissClick}>{t(labels.dismiss)}</Button>
</Row>
</Alert>
</Row>
</Column>
);
@@ -1,4 +1,5 @@
import { DataColumn, DataTable, Dialog, Icon, MenuItem, Modal, Row, Text } from '@umami/react-zen';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { DateDistance } from '@/components/common/DateDistance';
import Link from '@/components/common/Link';
@@ -17,6 +18,7 @@ export function AdminTeamsTable({
showActions?: boolean;
}) {
const { t, labels } = useMessages();
const router = useRouter();
const [deleteTeam, setDeleteTeam] = useState(null);
return (
@@ -62,7 +64,10 @@ export function AdminTeamsTable({
return (
<MenuButton>
<MenuItem href={`/admin/teams/${id}`} data-test="link-button-edit">
<MenuItem
onAction={() => router.push(`/admin/teams/${id}`)}
data-test="link-button-edit"
>
<Row alignItems="center" gap>
<Icon>
<Edit />
+6 -1
View File
@@ -1,4 +1,5 @@
import { DataColumn, DataTable, Icon, MenuItem, Modal, Row, Text } from '@umami/react-zen';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { DateDistance } from '@/components/common/DateDistance';
import Link from '@/components/common/Link';
@@ -18,6 +19,7 @@ export function UsersTable({
showActions?: boolean;
}) {
const { t, labels } = useMessages();
const router = useRouter();
const [deleteUser, setDeleteUser] = useState(null);
return (
@@ -53,7 +55,10 @@ export function UsersTable({
return (
<MenuButton>
<MenuItem href={`/admin/users/${id}`} data-test="link-button-edit">
<MenuItem
onAction={() => router.push(`/admin/users/${id}`)}
data-test="link-button-edit"
>
<Row alignItems="center" gap>
<Icon>
<Edit />
@@ -1,17 +1,27 @@
'use client';
import { Button, Column, Dialog, Modal, Row, Switch, Text, Tooltip, TooltipTrigger } from '@umami/react-zen';
import { useQueryClient } from '@tanstack/react-query';
import {
Button,
Column,
Dialog,
Modal,
Row,
Switch,
Text,
Tooltip,
TooltipTrigger,
} from '@umami/react-zen';
import { useState } from 'react';
import { Badge } from '@/components/common/Badge';
import { TypeConfirmationForm } from '@/components/common/TypeConfirmationForm';
import {
useDeleteQuery,
useMessages,
useUpdateQuery,
useTwoFactorStatusQuery,
useUserQuery,
useTwoFactorUserStatusQuery,
useUpdateQuery,
useUserQuery,
} from '@/components/hooks';
import { useQueryClient } from '@tanstack/react-query';
const CONFIRM_VALUE = 'RESET';
@@ -27,9 +37,11 @@ export function UserTwoFactorSettings({ userId }: { userId: string }) {
const { data: userData } = useUserQuery(userId);
const { mutateAsync: setUserRequired } = useUpdateQuery(`/admin/users/${userId}/2fa`);
const { mutateAsync: resetUserTwoFactor, isPending: isResetting, error: resetError } = useDeleteQuery(
`/admin/users/${userId}/2fa`,
);
const {
mutateAsync: resetUserTwoFactor,
isPending: isResetting,
error: resetError,
} = useDeleteQuery(`/admin/users/${userId}/2fa`);
const twoFactorEnabled = !!(userTfaData as any)?.isEnabled;
const twoFactorRequired = !!(userData as any)?.twoFactorRequired;
@@ -62,7 +74,19 @@ export function UserTwoFactorSettings({ userId }: { userId: string }) {
{t(messages.twoFactorRequireUserDescription)}
</Text>
<TooltipTrigger isDisabled={!isGlobalRequired}>
{isGlobalRequired ? (
<TooltipTrigger>
<Row alignItems="center" gap="3">
<Switch
isSelected={isGlobalRequired || twoFactorRequired}
isDisabled={isGlobalRequired}
onChange={handleToggle}
/>
<Text>{t(labels.twoFactorRequireUser)}</Text>
</Row>
<Tooltip>{t(labels.twoFactorGlobalActiveTooltip)}</Tooltip>
</TooltipTrigger>
) : (
<Row alignItems="center" gap="3">
<Switch
isSelected={isGlobalRequired || twoFactorRequired}
@@ -71,8 +95,7 @@ export function UserTwoFactorSettings({ userId }: { userId: string }) {
/>
<Text>{t(labels.twoFactorRequireUser)}</Text>
</Row>
<Tooltip>{t(labels.twoFactorGlobalActiveTooltip)}</Tooltip>
</TooltipTrigger>
)}
{twoFactorEnabled && (
<Column gap="3">
@@ -89,7 +112,7 @@ export function UserTwoFactorSettings({ userId }: { userId: string }) {
)}
</Column>
<Modal isOpen={showReset} isDismissable={true} onOpenChange={open => !open && setShowReset(false)}>
<Modal isOpen={showReset} onOpenChange={open => !open && setShowReset(false)}>
<Dialog title={t(labels.twoFactorReset)} style={{ width: 400 }}>
<TypeConfirmationForm
confirmationValue={CONFIRM_VALUE}
@@ -1,4 +1,5 @@
import { DataColumn, DataTable, Dialog, Icon, MenuItem, Modal, Row, Text } from '@umami/react-zen';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { WebsiteDeleteForm } from '@/app/(main)/websites/[websiteId]/settings/WebsiteDeleteForm';
import { DateDistance } from '@/components/common/DateDistance';
@@ -11,6 +12,7 @@ import { decodePunycodeDomain } from '@/lib/format';
export function AdminWebsitesTable({ data = [], ...props }: { data: any[] }) {
const { t, labels } = useMessages();
const router = useRouter();
const [deleteWebsite, setDeleteWebsite] = useState(null);
return (
@@ -62,7 +64,10 @@ export function AdminWebsitesTable({ data = [], ...props }: { data: any[] }) {
return (
<MenuButton>
<MenuItem href={`/admin/websites/${id}`} data-test="link-button-edit">
<MenuItem
onAction={() => router.push(`/admin/websites/${id}`)}
data-test="link-button-edit"
>
<Row alignItems="center" gap>
<Icon>
<Edit />
+5 -3
View File
@@ -53,7 +53,9 @@ export function BoardCloneForm({
}) {
const { t, labels, messages, getErrorMessage } = useMessages();
const { data: board, isLoading } = useBoardQuery(boardId);
const { mutateAsync, error, isPending, touch, toast } = useUpdateQuery(`/boards/${boardId}/clone`);
const { mutateAsync, error, isPending, touch, toast } = useUpdateQuery(
`/boards/${boardId}/clone`,
);
const values = getDefaultValues(board);
const boardType = getBoardType(board, { coerceDashboard: true });
const resolvedTeamId = board?.teamId;
@@ -95,8 +97,8 @@ export function BoardCloneForm({
? t(labels.link)
: t(labels.website);
const handleEntityChange = (value: string) => {
setValue('entityId', value, { shouldDirty: true });
const handleEntityChange = (value: string | number | null) => {
setValue('entityId', (value as string) ?? '', { shouldDirty: true });
};
return (
+3 -3
View File
@@ -107,13 +107,13 @@ export function BoardEditForm({
? t(labels.link)
: t(labels.website);
const handleTypeChange = (value: string) => {
const handleTypeChange = (value: string | number | null) => {
setValue('type', value as BoardType, { shouldDirty: true });
setValue('entityId', '', { shouldDirty: true });
};
const handleEntityChange = (value: string) => {
setValue('entityId', value, { shouldDirty: true });
const handleEntityChange = (value: string | number | null) => {
setValue('entityId', (value as string) ?? '', { shouldDirty: true });
};
return (
@@ -97,7 +97,10 @@ export function BoardComponentSelect({
const options = (entityType && field.optionsByEntityType?.[entityType]) ?? field.options;
const currentValue = defaults[field.name];
if (options?.length && !options.some(option => String(option.value) === String(currentValue))) {
if (
options?.length &&
!options.some(option => String(option.value) === String(currentValue))
) {
defaults[field.name] = options[0].value;
}
}
@@ -308,7 +311,10 @@ export function BoardComponentSelect({
<Text size="sm" color="muted">
{t(labels.type)}
</Text>
<Select value={selectedEntityType} onChange={handleEntityTypeChange}>
<Select
value={selectedEntityType}
onChange={value => handleEntityTypeChange(value as string)}
>
<ListItem id={BOARD_ENTITY_TYPES.website}>{t(labels.website)}</ListItem>
<ListItem id={BOARD_ENTITY_TYPES.pixel}>{t(labels.pixel)}</ListItem>
<ListItem id={BOARD_ENTITY_TYPES.link}>{t(labels.link)}</ListItem>
@@ -327,21 +333,21 @@ export function BoardComponentSelect({
pixelId={selectedEntityId}
teamId={teamId}
placeholder={t(labels.selectPixel)}
onChange={setSelectedEntityId}
onChange={value => setSelectedEntityId(value as string)}
/>
) : selectedEntityType === BOARD_ENTITY_TYPES.link ? (
<LinkSelect
linkId={selectedEntityId}
teamId={teamId}
placeholder={t(labels.selectLink)}
onChange={setSelectedEntityId}
onChange={value => setSelectedEntityId(value as string)}
/>
) : (
<WebsiteSelect
websiteId={selectedEntityId}
teamId={teamId}
placeholder={t(labels.selectWebsite)}
onChange={setSelectedEntityId}
onChange={value => setSelectedEntityId(value as string)}
/>
)}
</Column>
@@ -373,7 +379,7 @@ export function BoardComponentSelect({
{field.type === 'select' && (
<Select
value={String(configValues[field.name] ?? field.defaultValue ?? '')}
onChange={(value: string) => handleConfigChange(field.name, value)}
onChange={value => handleConfigChange(field.name, value as string)}
maxHeight={300}
popoverProps={{ style: { width: 220 } }}
>
@@ -415,7 +421,7 @@ export function BoardComponentSelect({
<>
<Select
value={String(configValues[field.name] ?? field.defaultValue ?? '')}
onChange={(value: string) => handleConfigChange(field.name, value)}
onChange={value => handleConfigChange(field.name, value as string)}
maxHeight={300}
popoverProps={{ style: { width: 220 } }}
>
+49 -32
View File
@@ -58,19 +58,29 @@ export function SettingsNav({
return (
<Column gap="2">
<Link href={renderUrl('/websites', false)} role="button" onClick={onItemClick}>
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
>
<IconLabel icon={<ArrowLeft />} label={isCollapsed ? '' : t(labels.back)} padding />
</Row>
</Focusable>
<Tooltip placement="right">{t(labels.back)}</Tooltip>
</TooltipTrigger>
{(() => {
const content = (
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
>
<IconLabel icon={<ArrowLeft />} label={isCollapsed ? '' : t(labels.back)} padding />
</Row>
</Focusable>
);
return isCollapsed ? (
<TooltipTrigger delay={0}>
{content}
<Tooltip placement="right">{t(labels.back)}</Tooltip>
</TooltipTrigger>
) : (
content
);
})()}
</Link>
{items.map(({ label: sectionLabel, items: sectionItems }, index) => (
<Column key={`${sectionLabel}${index}`} gap="1" marginBottom="1">
@@ -81,27 +91,34 @@ export function SettingsNav({
)}
{sectionItems.map(({ id, path, label, icon }) => {
const isSelected = selectedKey === id;
const content = (
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={isCollapsed ? '' : label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
</Focusable>
);
return (
<Link key={id} href={path} role="button" onClick={onItemClick}>
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={isCollapsed ? '' : label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
</Focusable>
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
{isCollapsed ? (
<TooltipTrigger delay={0}>
{content}
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
) : (
content
)}
</Link>
);
})}
@@ -24,8 +24,7 @@ export function DateRangeSetting() {
<DateFilter
value={date}
onChange={handleChange}
placement="bottom start"
style={{ minWidth: '250px' }}
buttonProps={{ style: { minWidth: '250px' } }}
/>
<Button onPress={handleReset}>{t(labels.reset)}</Button>
</Row>
@@ -34,7 +34,7 @@ export function LanguageSetting() {
onSearch={setSearch}
onOpenChange={handleOpen}
maxHeight={480}
style={{ minWidth: '250px' }}
buttonProps={{ style: { minWidth: '250px' } }}
>
{items.map(item => (
<ListItem key={item} id={item}>
@@ -30,7 +30,7 @@ export function TimezoneSetting() {
onSearch={setSearch}
onOpenChange={handleOpen}
maxHeight={480}
style={{ minWidth: '250px' }}
buttonProps={{ style: { minWidth: '250px' } }}
>
{items.map((item: any) => (
<ListItem key={item} id={item}>
@@ -1,4 +1,5 @@
'use client';
import { useQueryClient } from '@tanstack/react-query';
import { Column, Row, Switch, Text, Tooltip, TooltipTrigger } from '@umami/react-zen';
import { useState } from 'react';
import { Badge } from '@/components/common/Badge';
@@ -8,7 +9,6 @@ import { Panel } from '@/components/common/Panel';
import { useMessages, useTwoFactorStatusQuery } from '@/components/hooks';
import { TwoFactorDisableModal } from '@/components/modals/TwoFactorDisableModal';
import { TwoFactorSetupModal } from '@/components/modals/TwoFactorSetupModal';
import { useQueryClient } from '@tanstack/react-query';
export function UserSecurityPage() {
const { t, labels, messages } = useMessages();
@@ -61,7 +61,19 @@ export function UserSecurityPage() {
<Text>{t(messages.twoFactorUserDescription)}</Text>
)}
<TooltipTrigger isDisabled={!(isEnabled && isRequired)}>
{isEnabled && isRequired ? (
<TooltipTrigger>
<Row alignItems="center" gap="3">
<Switch
isSelected={isEnabled}
isDisabled={isEnabled && isRequired}
onChange={handleToggle}
/>
<Text>{t(labels.twoFactorEnable)}</Text>
</Row>
<Tooltip>{t(messages.twoFactorRequiredMessage)}</Tooltip>
</TooltipTrigger>
) : (
<Row alignItems="center" gap="3">
<Switch
isSelected={isEnabled}
@@ -70,8 +82,7 @@ export function UserSecurityPage() {
/>
<Text>{t(labels.twoFactorEnable)}</Text>
</Row>
<Tooltip>{t(messages.twoFactorRequiredMessage)}</Tooltip>
</TooltipTrigger>
)}
{isEnabled && isRequired && (
<Text size="sm" color="muted">
@@ -68,7 +68,7 @@ export function TeamEditForm({
)}
{allowEdit && (
<FormButtons justifyContent="flex-end">
<FormSubmitButton variant="primary" isPending={isPending}>
<FormSubmitButton variant="primary" isLoading={isPending}>
{t(labels.save)}
</FormSubmitButton>
</FormButtons>
@@ -1,12 +1,12 @@
'use client';
import { useQueryClient } from '@tanstack/react-query';
import { Column, Row, Switch, Text, Tooltip, TooltipTrigger } from '@umami/react-zen';
import {
useMessages,
useUpdateQuery,
useTwoFactorStatusQuery,
useTeamQuery,
useTwoFactorStatusQuery,
useUpdateQuery,
} from '@/components/hooks';
import { useQueryClient } from '@tanstack/react-query';
export function TeamTwoFactorSettings({ teamId }: { teamId: string }) {
const { t, labels, messages } = useMessages();
@@ -29,7 +29,19 @@ export function TeamTwoFactorSettings({ teamId }: { teamId: string }) {
<Column gap="4">
<Text weight="bold">{t(labels.twoFactorAuth)}</Text>
<TooltipTrigger isDisabled={!isGlobalRequired}>
{isGlobalRequired ? (
<TooltipTrigger>
<Row alignItems="center" gap="3">
<Switch
isSelected={isGlobalRequired || twoFactorRequired}
isDisabled={isGlobalRequired}
onChange={handleToggle}
/>
<Text>{t(labels.twoFactorRequireTeam)}</Text>
</Row>
<Tooltip>{t(labels.twoFactorGlobalActiveTooltip)}</Tooltip>
</TooltipTrigger>
) : (
<Row alignItems="center" gap="3">
<Switch
isSelected={isGlobalRequired || twoFactorRequired}
@@ -38,8 +50,7 @@ export function TeamTwoFactorSettings({ teamId }: { teamId: string }) {
/>
<Text>{t(labels.twoFactorRequireTeam)}</Text>
</Row>
<Tooltip>{t(labels.twoFactorGlobalActiveTooltip)}</Tooltip>
</TooltipTrigger>
)}
<Text size="sm" color="muted">
{t(messages.twoFactorRequireTeamDescription)}
@@ -26,14 +26,18 @@ export function Attribution({
type,
step,
}: AttributionProps) {
const { data, error, isLoading } = useResultQuery<any>('attribution', {
websiteId,
startDate,
endDate,
model,
type,
step,
});
const { data, error, isLoading } = useResultQuery<any>(
'attribution',
{
websiteId,
startDate,
endDate,
model,
type,
step,
},
{ enabled: !!step },
);
const { t, labels } = useMessages();
@@ -1,53 +1,96 @@
'use client';
import { Column, Grid, ListItem, SearchField, Select } from '@umami/react-zen';
import { Column, Grid, Label, ListItem, Loading, Select } from '@umami/react-zen';
import { useState } from 'react';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { useDateRange, useMessages } from '@/components/hooks';
import { Empty } from '@/components/common/Empty';
import { MultiSelect } from '@/components/common/MultiSelect';
import { useDateRange, useMessages, useWebsiteValuesQuery } from '@/components/hooks';
import { Attribution } from './Attribution';
export function AttributionPage({ websiteId }: { websiteId: string }) {
const [model, setModel] = useState('first-click');
const [type, setType] = useState('path');
const [step, setStep] = useState('/');
const [step, setStep] = useState('');
const [search, setSearch] = useState('');
const { t, labels } = useMessages();
const {
dateRange: { startDate, endDate },
} = useDateRange();
const { data, isLoading } = useWebsiteValuesQuery({
websiteId,
type,
search,
startDate,
endDate,
});
const items = data?.filter(({ value }) => value) || [];
const handleTypeChange = (value: any) => {
setType(value as string);
setStep('');
setSearch('');
};
const handleStepChange = (values: string[]) => {
setStep(values.filter(value => value !== step).pop() ?? '');
};
return (
<Column gap="6">
<WebsiteControls websiteId={websiteId} />
<Grid columns={{ base: '1fr', md: '1fr 1fr 1fr' }} gap>
<Column>
<Select label={t(labels.model)} value={model} defaultValue={model} onChange={setModel}>
<Select
label={t(labels.model)}
value={model}
defaultValue={model}
onChange={value => setModel(value as string)}
>
<ListItem id="first-click">{t(labels.firstClick)}</ListItem>
<ListItem id="last-click">{t(labels.lastClick)}</ListItem>
</Select>
</Column>
<Column>
<Select label={t(labels.type)} value={type} defaultValue={type} onChange={setType}>
<Select
label={t(labels.type)}
value={type}
defaultValue={type}
onChange={handleTypeChange}
>
<ListItem id="path">{t(labels.viewedPage)}</ListItem>
<ListItem id="event">{t(labels.triggeredEvent)}</ListItem>
</Select>
</Column>
<Column>
<SearchField
label={t(labels.conversionStep)}
value={step}
defaultValue={step}
onSearch={setStep}
delay={1000}
/>
<Label>{t(labels.conversionStep)}</Label>
<MultiSelect
value={step ? [step] : []}
onChange={handleStepChange}
searchValue={search}
onSearch={setSearch}
renderEmptyState={() => (isLoading ? <Loading icon="dots" /> : <Empty />)}
allowSearch
>
{items.map(({ value }) => (
<ListItem key={value} id={value}>
{value}
</ListItem>
))}
</MultiSelect>
</Column>
</Grid>
<Attribution
websiteId={websiteId}
startDate={startDate}
endDate={endDate}
model={model}
type={type}
step={step}
/>
{step ? (
<Attribution
websiteId={websiteId}
startDate={startDate}
endDate={endDate}
model={model}
type={type}
step={step}
/>
) : (
<Empty />
)}
</Column>
);
}
@@ -63,15 +63,11 @@ function PropertySelect({
aria-label="PropertySelect"
items={properties}
inputValue={value}
style={{ width: '100%' }}
onInputChange={v => {
onInputValueChange={v => {
setSearch(v);
onChange?.(v);
onPropertyChange?.(v);
}}
formValue="text"
allowsEmptyCollection
allowsCustomValue
renderEmptyState={() =>
isLoading ? (
<Loading placement="center" icon="dots" />
@@ -125,13 +121,9 @@ function ValueSelect({
aria-label="ValueSelect"
items={values}
inputValue={value}
style={{ width: '100%' }}
onInputChange={v => {
onInputValueChange={v => {
onChange?.(v);
}}
formValue="text"
allowsEmptyCollection
allowsCustomValue
renderEmptyState={() =>
isLoading ? (
<Loading placement="center" icon="dots" />
@@ -158,7 +150,7 @@ function OperatorSelect({
}) {
const { t, labels } = useMessages();
return (
<Select value={value} onChange={onChange}>
<Select value={value} onChange={v => onChange?.(v as string)}>
<ListItem id="eq">{t(labels.is)}</ListItem>
<ListItem id="neq">{t(labels.isNot)}</ListItem>
<ListItem id="c">{t(labels.contains)}</ListItem>
@@ -18,14 +18,7 @@ interface FunnelProps {
allowEdit?: boolean;
}
export function Funnel({
id,
name,
type,
parameters,
websiteId,
allowEdit = true,
}: FunnelProps) {
export function Funnel({ id, name, type, parameters, websiteId, allowEdit = true }: FunnelProps) {
const { t, labels } = useMessages();
const { pathname } = useNavigation();
const isSharePage = pathname.includes('/share/');
@@ -134,8 +127,8 @@ export function Funnel({
<Row alignItems="center" gap="6">
<ProgressBar
value={visitors || 0}
minValue={0}
maxValue={previous || 1}
min={0}
max={previous || 1}
style={{ width: '100%' }}
/>
<Row minWidth="90px" justifyContent="end">
@@ -93,8 +93,8 @@ export function Goal({
<Row alignItems="center" gap="6">
<ProgressBar
value={data?.num || 0}
minValue={0}
maxValue={data?.total || 1}
min={0}
max={data?.total || 1}
style={{ width: '100%' }}
/>
<Text weight="bold" size="4xl">
@@ -228,24 +228,25 @@ export function Journey({ websiteId, steps, startStep, endStep, view }: JourneyP
<Text truncate>{name}</Text>
</Row>
<div className={styles.count} title={nodeCount}>
<TooltipTrigger
delay={0}
isDisabled={columnIndex === 0 || (selectedNode && !selected)}
>
<Focusable>
<div>{formatLongNumber(nodeCount)}</div>
</Focusable>
<Tooltip placement="top" offset={20} showArrow>
<Text transform="lowercase" color="red">
{`${dropped}% ${t(labels.dropoff)}`}
</Text>
<Column>
<Text transform="lowercase">
{`${remaining}% ${t(labels.conversion)}`}
{columnIndex === 0 || (selectedNode && !selected) ? (
<div>{formatLongNumber(nodeCount)}</div>
) : (
<TooltipTrigger delay={0}>
<Focusable>
<div>{formatLongNumber(nodeCount)}</div>
</Focusable>
<Tooltip placement="top" sideOffset={20} showArrow>
<Text transform="lowercase" color="red">
{`${dropped}% ${t(labels.dropoff)}`}
</Text>
</Column>
</Tooltip>
</TooltipTrigger>
<Column>
<Text transform="lowercase">
{`${remaining}% ${t(labels.conversion)}`}
</Text>
</Column>
</Tooltip>
</TooltipTrigger>
)}
</div>
{columnIndex < columns.length &&
lines.map(([fromIndex, nodeIndex], i) => {
@@ -39,7 +39,12 @@ export function JourneysPage({ websiteId }: { websiteId: string }) {
<Column gap>
<WebsiteControls websiteId={websiteId} />
<Grid columns="repeat(3, 1fr)" gap>
<Select label={t(labels.steps)} value={steps} defaultValue={steps} onChange={setSteps}>
<Select
label={t(labels.steps)}
value={steps}
defaultValue={steps}
onChange={value => setSteps(Number(value))}
>
{JOURNEY_STEPS.map(step => (
<ListItem key={step} id={step}>
{step}
@@ -149,7 +149,7 @@ export function Performance({ websiteId, startDate, endDate, unit }: Performance
<Select
label="Percentile"
value={selectedPercentile}
onChange={(value: string) => setSelectedPercentile(value as 'p50' | 'p75' | 'p95')}
onChange={value => setSelectedPercentile(value as 'p50' | 'p75' | 'p95')}
>
{PERCENTILES.map(({ id, label }) => (
<ListItem key={id} id={id}>
@@ -92,9 +92,9 @@ export function Revenue({ websiteId, startDate, endDate, unit }: RevenueProps) {
<Row justifyContent="end">
<Select
value={revenueChartMode}
onChange={handleRevenueChartModeChange}
popoverProps={{ placement: 'bottom right' }}
style={{ width: 140 }}
onChange={value => handleRevenueChartModeChange(value as RevenueChartMode)}
popoverProps={{ side: 'bottom', align: 'end' }}
buttonProps={{ style: { width: 140 } }}
>
<ListItem id="period">{t(labels.period)}</ListItem>
<ListItem id="cumulative">{t(labels.cumulative)}</ListItem>
@@ -28,7 +28,7 @@ export function ExpandedViewModal({
};
return (
<Modal isOpen={!!view} onOpenChange={handleOpenChange} isDismissable>
<Modal isOpen={!!view} onOpenChange={handleOpenChange}>
<Dialog
style={{
maxWidth: 1320,
@@ -36,13 +36,13 @@ export function WebsiteMenu({ websiteId }: { websiteId: string }) {
<MoreHorizontal />
</Icon>
</Button>
<Popover placement="bottom">
<Menu onAction={handleAction}>
<Popover side="bottom">
<Menu>
{menuItems.map(({ id, label, icon, seperator }, index) => {
return (
<Fragment key={index}>
{seperator && <MenuSeparator />}
<MenuItem id={id}>
<MenuItem id={id} onAction={handleAction}>
<Icon>{icon}</Icon>
<Text>{label}</Text>
</MenuItem>
@@ -20,19 +20,30 @@ export function WebsiteNav({
return (
<Column gap="2" marginTop={isCollapsed ? '2' : undefined}>
<Link href={renderUrl('/websites', false)} role="button" onClick={onItemClick}>
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
>
<IconLabel icon={<ArrowLeft />} label={isCollapsed ? '' : t(labels.back)} padding />
</Row>
</Focusable>
<Tooltip placement="right">{t(labels.back)}</Tooltip>
</TooltipTrigger>
{isCollapsed ? (
<TooltipTrigger delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
>
<IconLabel icon={<ArrowLeft />} label="" padding />
</Row>
</Focusable>
<Tooltip placement="right">{t(labels.back)}</Tooltip>
</TooltipTrigger>
) : (
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
>
<IconLabel icon={<ArrowLeft />} label={t(labels.back)} padding />
</Row>
)}
</Link>
{items.map(({ label: sectionLabel, items: sectionItems }, index) => (
<Column key={`${sectionLabel}${index}`} gap="1" marginBottom="1">
@@ -45,25 +56,42 @@ export function WebsiteNav({
const isSelected = selectedKey === id;
return (
<Link key={id} href={path} role="button" onClick={onItemClick}>
<TooltipTrigger isDisabled={!isCollapsed} delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={isCollapsed ? '' : label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
</Focusable>
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
{isCollapsed ? (
<TooltipTrigger delay={0}>
<Focusable>
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label=""
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
</Focusable>
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
) : (
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
)}
</Link>
);
})}
@@ -109,7 +109,7 @@ export function EventProperties({ websiteId }: { websiteId: string }) {
<Label>{t(labels.event)}</Label>
<Select
value={eventName}
onChange={handleEventChange}
onChange={value => handleEventChange(value as string)}
allowSearch
searchValue={eventSearch}
onSearch={setEventSearch}
@@ -132,10 +132,8 @@ export function EventProperties({ websiteId }: { websiteId: string }) {
<Label>{t(labels.property)}</Label>
<ComboBox
inputValue={propertyName}
onInputChange={setPropertyName}
onInputValueChange={setPropertyName}
isDisabled={!eventName}
allowsCustomValue
allowsEmptyCollection
>
{properties.map((field: { propertyName: string }) => (
<ListItem key={field.propertyName} id={field.propertyName}>
@@ -110,7 +110,7 @@ const PropertiesButton = props => {
</Icon>
</Row>
</Button>
<Popover placement="right">
<Popover side="right">
<Dialog>
<EventData {...props} />
</Dialog>
@@ -1,11 +1,11 @@
'use client';
import { Column, Dialog, Modal, type ModalProps } from '@umami/react-zen';
import { Column, Dialog, Sheet, type SheetProps } from '@umami/react-zen';
import { ReplayPlayback } from '@/app/(main)/websites/[websiteId]/replays/[replayId]/ReplayPlayback';
import { useNavigation } from '@/components/hooks';
import { buildPath } from '@/lib/url';
import styles from './ReplayModal.module.css';
export interface ReplayModalProps extends ModalProps {
export interface ReplayModalProps extends SheetProps {
websiteId: string;
replayId?: string;
}
@@ -34,17 +34,16 @@ export function ReplayModal({ websiteId, replayId, className, ...props }: Replay
};
return (
<Modal
<Sheet
{...props}
placement="bottom"
offset="80px"
side="bottom"
size="calc(100dvh - 80px)"
className={modalClassName}
isOpen={!!activeReplayId}
onOpenChange={handleOpenChange}
isDismissable
>
<Column height="100%">
<Dialog variant="sheet" className={styles.sheet}>
<Dialog className={styles.sheet}>
{({ close }) => (
<Column padding="6">
{activeReplayId && (
@@ -54,6 +53,6 @@ export function ReplayModal({ websiteId, replayId, className, ...props }: Replay
)}
</Dialog>
</Column>
</Modal>
</Sheet>
);
}
@@ -76,7 +76,7 @@ export function ReplayPlayback({
<Bookmark fill="none" />
</Icon>
</Button>
<Popover placement="bottom end">
<Popover side="bottom" align="end">
<Dialog title={t(labels.saveReplay)} style={{ width: '300px' }}>
{({ close }) => (
<ReplaySaveForm
@@ -98,7 +98,7 @@ const PropertiesButton = props => {
</Icon>
</Row>
</Button>
<Popover placement="right">
<Popover side="right">
<Dialog>
<EventData {...props} />
</Dialog>
@@ -1,10 +1,10 @@
'use client';
import { Column, Dialog, Modal, type ModalProps } from '@umami/react-zen';
import { Column, Dialog, Sheet, type SheetProps } from '@umami/react-zen';
import { SessionProfile } from '@/app/(main)/websites/[websiteId]/sessions/SessionProfile';
import { useNavigation } from '@/components/hooks';
import styles from './SessionModal.module.css';
export interface SessionModalProps extends ModalProps {
export interface SessionModalProps extends SheetProps {
websiteId: string;
}
@@ -23,17 +23,16 @@ export function SessionModal({ websiteId, className, ...props }: SessionModalPro
};
return (
<Modal
placement="bottom"
offset="80px"
<Sheet
side="bottom"
size="calc(100dvh - 80px)"
className={[styles.modal, className].filter(Boolean).join(' ')}
isOpen={!!session}
onOpenChange={handleOpenChange}
isDismissable
{...props}
>
<Column height="100%">
<Dialog variant="sheet" className="rounded-lg">
<Dialog className="rounded-lg">
{({ close }) => (
<Column padding="10">
<SessionProfile
@@ -46,6 +45,6 @@ export function SessionModal({ websiteId, className, ...props }: SessionModalPro
)}
</Dialog>
</Column>
</Modal>
</Sheet>
);
}
@@ -1,9 +1,9 @@
'use client';
import { Column, Dialog, Modal } from '@umami/react-zen';
import { Column, Dialog, Sheet } from '@umami/react-zen';
import { useRouter, useSearchParams } from 'next/navigation';
import { buildPath } from '@/lib/url';
import { SessionProfile } from './SessionProfile';
import styles from './SessionModal.module.css';
import { SessionProfile } from './SessionProfile';
export function SessionProfileModal({
websiteId,
@@ -29,21 +29,20 @@ export function SessionProfileModal({
};
return (
<Modal
placement="bottom"
offset="80px"
<Sheet
side="bottom"
size="calc(100dvh - 80px)"
className={styles.modal}
isOpen
onOpenChange={handleOpenChange}
isDismissable
>
<Column height="100%">
<Dialog variant="sheet" className="rounded-lg">
<Dialog className="rounded-lg">
<Column padding="10">
<SessionProfile websiteId={websiteId} sessionId={sessionId} onClose={closeModal} />
</Column>
</Dialog>
</Column>
</Modal>
</Sheet>
);
}
@@ -85,12 +85,7 @@ export function SessionProperties({ websiteId }: { websiteId: string }) {
>
<Column gap="1" style={{ minWidth: 0 }}>
<Label>{t(labels.property)}</Label>
<ComboBox
inputValue={propertyName}
onInputChange={setPropertyName}
allowsCustomValue
allowsEmptyCollection
>
<ComboBox inputValue={propertyName} onInputValueChange={setPropertyName}>
{properties.map((field: { propertyName: string }) => (
<ListItem key={field.propertyName} id={field.propertyName}>
{field.propertyName}
@@ -52,7 +52,7 @@ export function SessionReplaysDataTable({
)}
<DataGrid query={queryResult} allowPaging>
{({ data }) => (
<SessionReplaysTable data={data} onPlay={handlePlay} selectedId={selectedId} />
<SessionReplaysTable data={data} onPlay={handlePlay as any} selectedId={selectedId} />
)}
</DataGrid>
</Column>
@@ -160,13 +160,12 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
{heatmapEnabled && (
<Slider
label={`Heatmap ${t(labels.sampleRate).toLowerCase()}`}
minValue={0.05}
maxValue={1}
min={0.05}
max={1}
step={0.05}
value={heatmapSampleRate}
onChange={v => setHeatmapSampleRate(Array.isArray(v) ? v[0] : v)}
showValue
formatOptions={{ style: 'percent', maximumFractionDigits: 0 }}
style={{ maxWidth: '360px' }}
/>
)}
@@ -174,25 +173,32 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
<>
<Slider
label={`Replay ${t(labels.sampleRate).toLowerCase()}`}
minValue={0.05}
maxValue={1}
min={0.05}
max={1}
step={0.05}
value={sampleRate}
onChange={v => setSampleRate(Array.isArray(v) ? v[0] : v)}
showValue
formatOptions={{ style: 'percent', maximumFractionDigits: 0 }}
style={{ maxWidth: '360px' }}
/>
<Column gap="1">
<Label>{t(labels.maskLevel)}</Label>
<Select value={maskLevel} onChange={setMaskLevel} style={{ maxWidth: '360px' }}>
<Select
value={maskLevel}
onChange={v => setMaskLevel(v as typeof maskLevel)}
buttonProps={{ style: { maxWidth: '360px' } }}
>
<ListItem id="strict">strict</ListItem>
<ListItem id="moderate">moderate</ListItem>
</Select>
</Column>
<Column gap="1">
<Label>{t(labels.maxDuration)}</Label>
<Select value={maxDuration} onChange={setMaxDuration} style={{ maxWidth: '360px' }}>
<Select
value={maxDuration}
onChange={v => setMaxDuration(v as string)}
buttonProps={{ style: { maxWidth: '360px' } }}
>
<ListItem id="300000">5 minutes</ListItem>
<ListItem id="600000">10 minutes</ListItem>
<ListItem id="900000">15 minutes</ListItem>
@@ -9,7 +9,7 @@ import {
Select,
Text,
} from '@umami/react-zen';
import { type Key, useState } from 'react';
import { useState } from 'react';
import {
useLoginQuery,
useMessages,
@@ -59,7 +59,7 @@ export function WebsiteTransferForm({
);
};
const handleChange = (key: Key) => {
const handleChange = (key: string | number | null) => {
setTeamId(key as string);
};
@@ -74,7 +74,7 @@ export function WebsiteTransferForm({
</Text>
<FormField name="teamId">
{!isTeamWebsite && (
<Select onSelectionChange={handleChange} selectedKey={teamId}>
<Select onChange={handleChange} value={teamId}>
{items.map(({ id, name }) => {
return (
<ListItem key={`${id}`} id={`${id}`}>
@@ -89,7 +89,7 @@ export function WebsiteTransferForm({
<Button onPress={onClose}>{t(labels.cancel)}</Button>
<FormSubmitButton
variant="primary"
isPending={isPending}
isLoading={isPending}
isDisabled={!isTeamWebsite && !teamId}
>
{t(labels.transfer)}
+1 -16
View File
@@ -1,7 +1,6 @@
'use client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { RouterProvider, ZenProvider } from '@umami/react-zen';
import { useRouter } from 'next/navigation';
import { NextIntlClientProvider } from 'next-intl';
import { useEffect } from 'react';
import { ErrorBoundary } from '@/components/common/ErrorBoundary';
@@ -34,23 +33,9 @@ function MessagesProvider({ children }) {
}
export function Providers({ children }) {
const router = useRouter();
function navigate(url: string) {
if (shouldUseNativeLink(url)) {
window.location.href = url;
} else {
router.push(url);
}
}
function shouldUseNativeLink(url: string) {
return url.startsWith('http');
}
return (
<ZenProvider>
<RouterProvider navigate={navigate}>
<RouterProvider>
<MessagesProvider>
<QueryClientProvider client={client}>
<ErrorBoundary>{children}</ErrorBoundary>
+36 -20
View File
@@ -177,26 +177,42 @@ export function ShareNav({
const isSelected = selectedKey === id;
return (
<Link key={id} href={path} role="button" onClick={onItemClick}>
<TooltipTrigger isDisabled={!collapsed} delay={0}>
<Focusable>
<Row
alignItems="center"
justifyContent={collapsed ? 'center' : undefined}
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={collapsed ? '' : label}
weight={isSelected ? 'bold' : undefined}
{...(!collapsed && { padding: true })}
/>
</Row>
</Focusable>
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
{collapsed ? (
<TooltipTrigger delay={0}>
<Focusable>
<Row
alignItems="center"
justifyContent="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label=""
weight={isSelected ? 'bold' : undefined}
/>
</Row>
</Focusable>
<Tooltip placement="right">{label}</Tooltip>
</TooltipTrigger>
) : (
<Row
alignItems="center"
hover={{ backgroundColor: 'surface-sunken' }}
backgroundColor={isSelected ? 'surface-sunken' : undefined}
borderRadius
minHeight="40px"
>
<IconLabel
icon={icon}
label={label}
weight={isSelected ? 'bold' : undefined}
padding
/>
</Row>
)}
</Link>
);
})}
-2
View File
@@ -1,8 +1,6 @@
import { type ComboBoxProps, type ListProps, ComboBox as ZenComboBox } from '@umami/react-zen';
const defaultListProps: Partial<ListProps> = {
shouldSelectOnPressUp: true,
shouldFocusOnHover: false,
style: {
maxHeight: 'min(400px, calc(100dvh - 8rem))',
},
-2
View File
@@ -64,8 +64,6 @@ export function MultiSelect({
value={value}
onChange={onChange}
showCheckmark
shouldSelectOnPressUp
shouldFocusOnHover={false}
style={listStyle}
renderEmptyState={renderEmptyState}
>
+6 -3
View File
@@ -1,6 +1,6 @@
'use client';
import { useRef, ClipboardEvent, KeyboardEvent } from 'react';
import { Row, TextField } from '@umami/react-zen';
import { type ClipboardEvent, type KeyboardEvent, useRef } from 'react';
interface OtpInputProps {
value: string;
@@ -36,7 +36,10 @@ export function OtpInput({ value, onChange, onComplete, disabled }: OtpInputProp
}
};
const handleKeyDown = (index: number, e: KeyboardEvent<HTMLInputElement>) => {
const handleKeyDown = (
index: number,
e: KeyboardEvent<HTMLInputElement & HTMLTextAreaElement>,
) => {
if (e.key === 'Backspace') {
if (digits[index]) {
update(index, '');
@@ -51,7 +54,7 @@ export function OtpInput({ value, onChange, onComplete, disabled }: OtpInputProp
}
};
const handlePaste = (e: ClipboardEvent<HTMLInputElement>) => {
const handlePaste = (e: ClipboardEvent<HTMLInputElement & HTMLTextAreaElement>) => {
e.preventDefault();
const pasted = e.clipboardData.getData('text').replace(/\D/g, '').slice(0, LENGTH);
const next = Array.from({ length: LENGTH }, (_, i) => pasted[i] ?? '');
+6 -2
View File
@@ -1,5 +1,5 @@
'use client';
import { AlertBanner, Column, type ColumnProps, Loading } from '@umami/react-zen';
import { Alert, AlertTitle, Column, type ColumnProps, Loading } from '@umami/react-zen';
import type { ReactNode } from 'react';
import { useMessages } from '@/components/hooks';
@@ -20,7 +20,11 @@ export function PageBody({
const { t, messages } = useMessages();
if (error) {
return <AlertBanner title={t(messages.error)} variant="error" />;
return (
<Alert variant="danger">
<AlertTitle>{t(messages.error)}</AlertTitle>
</Alert>
);
}
if (isLoading) {
+15 -6
View File
@@ -65,14 +65,23 @@ export function Panel({
{(allowFullscreen || toolbar) && (
<Row justifyContent="flex-end" alignItems="center" gap>
{toolbar}
{allowFullscreen && (
<TooltipTrigger delay={0} isDisabled={isFullscreen}>
{allowFullscreen &&
(isFullscreen ? (
<Button size="sm" variant="quiet" onPress={handleFullscreen}>
<Icon>{isFullscreen ? <X /> : <Maximize />}</Icon>
<Icon>
<X />
</Icon>
</Button>
<Tooltip>{t(labels.maximize)}</Tooltip>
</TooltipTrigger>
)}
) : (
<TooltipTrigger delay={0}>
<Button size="sm" variant="quiet" onPress={handleFullscreen}>
<Icon>
<Maximize />
</Icon>
</Button>
<Tooltip>{t(labels.maximize)}</Tooltip>
</TooltipTrigger>
))}
</Row>
)}
{children}
+1 -1
View File
@@ -10,7 +10,7 @@ export function ActionSelect({ value = 'path', onChange }: ActionSelectProps) {
const { t, labels } = useMessages();
return (
<Select value={value} onChange={onChange}>
<Select value={value} onChange={val => onChange?.(val as string)}>
<ListItem id="path">{t(labels.viewedPage)}</ListItem>
<ListItem id="event">{t(labels.triggeredEvent)}</ListItem>
</Select>
+1 -1
View File
@@ -60,7 +60,7 @@ export function BoardSelect({
allowSearch={true}
searchValue={search}
onSearch={setSearch}
onChange={handleChange}
onChange={value => handleChange(value as string)}
onOpenChange={handleOpenChange}
renderValue={renderValue}
buttonProps={{
+8 -2
View File
@@ -5,7 +5,7 @@ import { useMessages, useMobile } from '@/components/hooks';
import { DatePickerForm } from '@/components/metrics/DatePickerForm';
import { getMaxSelectableDate, parseDateRange } from '@/lib/date';
export interface DateFilterProps extends SelectProps {
export interface DateFilterProps extends Omit<SelectProps, 'value' | 'onChange'> {
value?: string;
onChange?: (value: string) => void;
showAllTime?: boolean;
@@ -101,6 +101,8 @@ export function DateFilter({
const selectedValue = value.endsWith(':all') ? 'all' : value;
const [side, align] = String(placement).split(' ');
return (
<>
<Select
@@ -109,7 +111,11 @@ export function DateFilter({
placeholder={t(labels.selectDate)}
onChange={handleChange}
renderValue={renderValue}
popoverProps={{ placement, style: { minWidth: 200 } }}
popoverProps={{
side: side as any,
align: (align === 'top' ? 'start' : align === 'bottom' ? 'end' : align) as any,
style: { minWidth: 200 },
}}
isFullscreen={isMobile}
>
{options.map(({ label, value, divider }: any) => {
+2 -7
View File
@@ -10,7 +10,7 @@ import type { CSSProperties, ReactNode } from 'react';
import { IconLabel } from '@/components/common/IconLabel';
import { useMobile } from '@/components/hooks';
export interface DialogButtonProps extends Omit<ButtonProps, 'children'> {
export interface DialogButtonProps extends Omit<ButtonProps, 'children' | 'title'> {
icon?: ReactNode;
label?: ReactNode;
title?: ReactNode;
@@ -57,11 +57,7 @@ export function DialogButton({
}
const dialog = (
<Dialog
variant={isMobile ? 'sheet' : undefined}
title={title === undefined ? label : title}
style={style}
>
<Dialog title={title === undefined ? label : title} style={style}>
{children}
</Dialog>
);
@@ -71,7 +67,6 @@ export function DialogButton({
<Modal
isOpen={isOpen}
onOpenChange={onOpenChange}
isDismissable
placement={isMobile ? 'fullscreen' : 'center'}
>
{dialog}
+14 -9
View File
@@ -88,11 +88,8 @@ export function FieldFilters({
<Plus />
</Icon>
</Button>
<Popover placement={isMobile ? 'left' : 'bottom start'} shouldFlip>
<Menu
onAction={handleAdd}
style={{ maxHeight: 'calc(100vh - 2rem)', overflowY: 'auto' }}
>
<Popover side={isMobile ? 'left' : 'bottom'} align={isMobile ? undefined : 'start'}>
<Menu style={{ maxHeight: 'calc(100vh - 2rem)', overflowY: 'auto' }}>
{groupLabels.map(({ key: groupKey, label }) => {
const groupFields = groupedFields[groupKey];
if (!groupFields || groupFields.length === 0) return null;
@@ -100,7 +97,7 @@ export function FieldFilters({
<MenuSection key={groupKey} title={label}>
{groupFields.map(field => {
return (
<MenuItem key={field.name} id={field.name}>
<MenuItem key={field.name} id={field.name} onAction={handleAdd}>
{field.filterLabel}
</MenuItem>
);
@@ -118,7 +115,7 @@ export function FieldFilters({
paddingRight="3"
marginRight="6"
>
<List onAction={handleAdd}>
<List>
{groupLabels.map(({ key: groupKey, label }) => {
const groupFields = groupedFields[groupKey];
if (!groupFields || groupFields.length === 0) return null;
@@ -127,7 +124,11 @@ export function FieldFilters({
<ListSection key={groupKey} title={label}>
{groupFields.map(field => {
return (
<ListItem key={field.name} id={field.name}>
<ListItem
key={field.name}
id={field.name}
onClick={() => handleAdd(field.name)}
>
{field.filterLabel}
</ListItem>
);
@@ -142,7 +143,11 @@ export function FieldFilters({
<Row alignItems="center" gap>
<Column gap="1">
<Label>{t(labels.match)}</Label>
<Select value={match} onChange={onMatchChange} style={{ width: 150 }}>
<Select
value={match}
onChange={value => onMatchChange(value as string)}
buttonProps={{ style: { width: 150 } }}
>
<ListItem id="all">{t(labels.matchAll)}</ListItem>
<ListItem id="any">{t(labels.matchAny)}</ListItem>
</Select>
+8 -9
View File
@@ -29,13 +29,7 @@ export function FilterBar({ websiteId }: { websiteId?: string }) {
const { t, labels } = useMessages();
const { isMobile } = useMobile();
const { formatValue } = useFormat();
const {
router,
pathname,
updateParams,
replaceParams,
query,
} = useNavigation();
const { router, pathname, updateParams, replaceParams, query } = useNavigation();
const { segment, cohort } = query;
const { filters, eventPropertyFilters, sessionPropertyFilters, operatorLabels } = useFilters();
const { data, isLoading } = useWebsiteSegmentQuery(websiteId, segment || cohort);
@@ -92,7 +86,13 @@ export function FilterBar({ websiteId }: { websiteId?: string }) {
router.push(updateParams({ [type]: undefined }));
};
if (!filters.length && !eventPropertyFilters.length && !sessionPropertyFilters.length && !segment && !cohort) {
if (
!filters.length &&
!eventPropertyFilters.length &&
!sessionPropertyFilters.length &&
!segment &&
!cohort
) {
return null;
}
@@ -181,7 +181,6 @@ export function FilterBar({ websiteId }: { websiteId?: string }) {
)}
<Modal placement={isMobile ? 'fullscreen' : 'center'}>
<Dialog
variant={isMobile ? 'sheet' : undefined}
title={t(labels.segment)}
style={{
width: isMobile ? '100%' : '800px',
-1
View File
@@ -18,7 +18,6 @@ export function FilterButtons({ items, value, onChange }: FilterButtonsProps) {
onChange?.(nextValue);
}
}}
disallowEmptySelection={true}
>
{items.map(({ id, label }) => (
<ToggleGroupItem key={id} id={id}>
+1 -1
View File
@@ -18,7 +18,7 @@ export function LanguageButton() {
<Globe />
</Icon>
</Button>
<Popover placement="bottom end">
<Popover side="bottom" align="end">
<Dialog>
<Grid columns="repeat(3, minmax(200px, 1fr))" overflow="hidden">
{items.map(({ value, label }) => {
+1 -1
View File
@@ -64,7 +64,7 @@ export function LinkSelect({
allowSearch={true}
searchValue={search}
onSearch={setSearch}
onChange={handleChange}
onChange={value => handleChange(value as string)}
onOpenChange={handleOpenChange}
renderValue={renderValue}
buttonProps={{
+2 -5
View File
@@ -1,7 +1,7 @@
import { type ComboBoxProps, ListItem, Loading, useDebounce } from '@umami/react-zen';
import { ComboBox } from '@/components/common/ComboBox';
import { endOfDay, subMonths } from 'date-fns';
import { type SetStateAction, useMemo, useState } from 'react';
import { ComboBox } from '@/components/common/ComboBox';
import { Empty } from '@/components/common/Empty';
import { useMessages, useWebsiteValuesQuery } from '@/components/hooks';
@@ -49,14 +49,11 @@ export function LookupField({
{...props}
items={items}
inputValue={value}
onInputChange={value => {
onInputValueChange={value => {
handleSearch(value);
onChange?.(value);
onValueChange?.(value);
}}
formValue="text"
allowsEmptyCollection
allowsCustomValue
renderEmptyState={() =>
isLoading ? (
<Loading placement="center" icon="dots" />
+17 -4
View File
@@ -1,5 +1,12 @@
import { Button, DialogTrigger, Icon, Menu, Popover } from '@umami/react-zen';
import type { Key, ReactNode } from 'react';
import {
Children,
cloneElement,
isValidElement,
type Key,
type ReactElement,
type ReactNode,
} from 'react';
import { Ellipsis } from '@/components/icons';
export function MenuButton({
@@ -22,9 +29,15 @@ export function MenuButton({
<Ellipsis />
</Icon>
</Button>
<Popover placement="bottom start">
<Menu aria-label="menu" onAction={handleAction} style={{ minWidth: '140px' }}>
{children}
<Popover side="bottom" align="start">
<Menu aria-label="menu" style={{ minWidth: '140px' }}>
{Children.map(children, child =>
isValidElement(child)
? cloneElement(child as ReactElement<{ onAction?: (key: Key) => void }>, {
onAction: handleAction,
})
: child,
)}
</Menu>
</Popover>
</DialogTrigger>
+4 -4
View File
@@ -1,4 +1,4 @@
import { Button, Dialog, type DialogProps, DialogTrigger, Icon, Modal } from '@umami/react-zen';
import { Button, Dialog, type DialogProps, DialogTrigger, Icon, Sheet } from '@umami/react-zen';
import { Menu } from '@/components/icons';
export function MobileMenuButton(props: DialogProps) {
@@ -9,9 +9,9 @@ export function MobileMenuButton(props: DialogProps) {
<Menu />
</Icon>
</Button>
<Modal placement="left" offset="80px">
<Dialog variant="sheet" {...props} style={{ width: 'auto' }} />
</Modal>
<Sheet side="left">
<Dialog {...props} style={{ width: 'auto' }} />
</Sheet>
</DialogTrigger>
);
}
+2 -2
View File
@@ -24,7 +24,7 @@ export function MonthSelect({ date = new Date(), onChange }) {
return (
<Row gap>
<Select value={month} onChange={handleMonthChange}>
<Select value={month} onChange={value => handleMonthChange(value as number)}>
{months.map(m => {
return (
<ListItem id={m} key={m}>
@@ -33,7 +33,7 @@ export function MonthSelect({ date = new Date(), onChange }) {
);
})}
</Select>
<Select value={year} onChange={handleYearChange}>
<Select value={year} onChange={value => handleYearChange(value as number)}>
{years.map(y => {
return (
<ListItem id={y} key={y}>
+18 -6
View File
@@ -51,6 +51,14 @@ export function NavButton({ showText = true }: TeamsButtonProps) {
}
};
const handleNavigate = (url: string) => {
if (cloudMode) {
window.location.href = url;
} else {
router.push(url);
}
};
return (
<MenuTrigger>
<Pressable>
@@ -77,25 +85,29 @@ export function NavButton({ showText = true }: TeamsButtonProps) {
)}
</Row>
</Pressable>
<Popover placement="bottom start">
<Popover side="bottom" align="start">
<Column minWidth="300px">
<Menu autoFocus="last">
<Menu>
<SubmenuTrigger>
<MenuItem id="teams" showChecked={false} showSubMenuIcon>
<IconLabel icon={<Switch />} label={t(labels.switchAccount)} />
</MenuItem>
<Popover placement={isMobile ? 'bottom start' : 'right top'}>
<Popover side={isMobile ? 'bottom' : 'right'} align="start">
<Column minWidth="300px">
<Menu selectionMode="single" selectedKeys={selectedKeys} onAction={handleAction}>
<Menu selectionMode="single" selectedKeys={selectedKeys}>
<MenuSection title={t(labels.myAccount)}>
<MenuItem id="user">
<MenuItem id="user" onAction={handleAction}>
<IconLabel icon={<User />} label={user.username} />
</MenuItem>
</MenuSection>
<MenuSeparator />
<MenuSection title={t(labels.teams)}>
{user?.teams?.map(({ id, name }) => (
<MenuItem key={id} id={id} href={getUrl(`/teams/${id}`)}>
<MenuItem
key={id}
id={id}
onAction={() => handleNavigate(getUrl(`/teams/${id}`))}
>
<IconLabel icon={<Users />}>
<Text wrap="nowrap">{name}</Text>
</IconLabel>
+1 -1
View File
@@ -64,7 +64,7 @@ export function PixelSelect({
allowSearch={true}
searchValue={search}
onSearch={setSearch}
onChange={handleChange}
onChange={value => handleChange(value as string)}
onOpenChange={handleOpenChange}
renderValue={renderValue}
buttonProps={{
+1 -1
View File
@@ -15,7 +15,7 @@ export function PreferencesButton() {
<Settings />
</Icon>
</Button>
<Popover placement="bottom end">
<Popover side="bottom" align="end">
<Panel gap="3">
<Column>
<Label>{t(labels.timezone)}</Label>
+4 -4
View File
@@ -17,7 +17,7 @@ import { LockKeyhole, LogOut, UserCircle } from '@/components/icons';
export function ProfileButton() {
const { t, labels } = useMessages();
const { user } = useLoginQuery();
const { renderUrl } = useNavigation();
const { renderUrl, router } = useNavigation();
const items = [
{
@@ -49,15 +49,15 @@ export function ProfileButton() {
<UserCircle />
</Icon>
</Button>
<Popover placement="bottom end">
<Menu autoFocus="last">
<Popover side="bottom" align="end">
<Menu>
<MenuSection title={user.username}>
<MenuSeparator />
{items.map(({ id, path, label, icon, separator }) => {
return (
<Fragment key={id}>
{separator && <MenuSeparator />}
<MenuItem id={id} href={path}>
<MenuItem id={id} onAction={() => router.push(path)}>
<Row alignItems="center" gap>
<Icon>{icon}</Icon>
<Text>{label}</Text>
+5 -5
View File
@@ -75,15 +75,15 @@ export function ReportEditButton({
<MoreHorizontal />
</Icon>
</Button>
<Popover placement="bottom">
<Menu onAction={handleAction}>
<MenuItem id="edit">
<Popover side="bottom">
<Menu>
<MenuItem id="edit" onAction={handleAction}>
<Icon>
<Edit />
</Icon>
<Text>{t(labels.edit)}</Text>
</MenuItem>
<MenuItem id="delete">
<MenuItem id="delete" onAction={handleAction}>
<Icon>
<Trash />
</Icon>
@@ -103,7 +103,7 @@ export function ReportEditButton({
>
{children}
</DialogButton>
<Modal isOpen={showDelete} isDismissable={true} onOpenChange={open => !open && handleClose()}>
<Modal isOpen={showDelete} onOpenChange={open => !open && handleClose()}>
<AlertDialog
title={t(labels.delete)}
onConfirm={handleDelete}
@@ -17,7 +17,6 @@ export function SegmentSaveButton({ websiteId }: { websiteId: string }) {
</Button>
<Modal placement={isMobile ? 'fullscreen' : 'center'}>
<Dialog
variant={isMobile ? 'sheet' : undefined}
title={t(labels.segment)}
style={{
width: isMobile ? '100%' : '800px',
+32 -7
View File
@@ -48,26 +48,51 @@ export function SettingsButton() {
<UserCircle />
</Icon>
</Button>
<Popover placement="bottom end">
<Menu autoFocus="last" onAction={handleAction}>
<Popover side="bottom" align="end">
<Menu>
<MenuSection title={user.username}>
<MenuSeparator />
<MenuItem id="/settings" icon={<Settings />} label={t(labels.settings)} />
<MenuItem
id="/settings"
icon={<Settings />}
label={t(labels.settings)}
onAction={handleAction}
/>
{!cloudMode && user.isAdmin && (
<MenuItem id="/admin" icon={<LockKeyhole />} label={t(labels.admin)} />
<MenuItem
id="/admin"
icon={<LockKeyhole />}
label={t(labels.admin)}
onAction={handleAction}
/>
)}
{cloudMode && (
<>
<MenuItem id="/docs" icon={<BookText />} label={t(labels.documentation)}>
<MenuItem
id="/docs"
icon={<BookText />}
label={t(labels.documentation)}
onAction={handleAction}
>
<Icon color="muted">
<ExternalLink />
</Icon>
</MenuItem>
<MenuItem id="/settings/support" icon={<LifeBuoy />} label={t(labels.support)} />
<MenuItem
id="/settings/support"
icon={<LifeBuoy />}
label={t(labels.support)}
onAction={handleAction}
/>
</>
)}
<MenuSeparator />
<MenuItem id="/logout" icon={<LogOut />} label={t(labels.logout)} />
<MenuItem
id="/logout"
icon={<LogOut />}
label={t(labels.logout)}
onAction={handleAction}
/>
</MenuSection>
</Menu>
</Popover>
+12 -4
View File
@@ -34,6 +34,14 @@ export function TeamsButton() {
return cloudMode ? `${process.env.cloudUrl}${url}` : url;
};
const handleNavigate = (url: string) => {
if (cloudMode) {
window.location.href = url;
} else {
router.push(url);
}
};
const handleAction = async (key: Key) => {
if (key === 'user') {
removeItem(LAST_TEAM_CONFIG);
@@ -63,18 +71,18 @@ export function TeamsButton() {
<ChevronRight />
</Icon>
</Button>
<Popover placement="bottom start">
<Popover side="bottom" align="start">
<Column minWidth="300px">
<Menu selectionMode="single" selectedKeys={selectedKeys} onAction={handleAction}>
<Menu selectionMode="single" selectedKeys={selectedKeys}>
<MenuSection title={t(labels.myAccount)}>
<MenuItem id="user">
<MenuItem id="user" onAction={handleAction}>
<IconLabel icon={<User />} label={user.username} />
</MenuItem>
</MenuSection>
<MenuSeparator />
<MenuSection title={t(labels.teams)}>
{user?.teams?.map(({ id, name }) => (
<MenuItem key={id} id={id} href={getUrl(`/teams/${id}`)}>
<MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
<IconLabel icon={<Users />}>
<Text wrap="nowrap">{name}</Text>
</IconLabel>
+3 -3
View File
@@ -56,9 +56,9 @@ export function UnitFilter() {
<Row>
<Select
value={selectedUnit}
onChange={handleChange}
popoverProps={{ placement: 'bottom right' }}
style={{ width: 100 }}
onChange={value => handleChange(value as string)}
popoverProps={{ side: 'bottom', align: 'end' }}
buttonProps={{ style: { width: 100 } }}
>
{options.map(({ id, label }) => (
<ListItem key={id} id={id}>
+60 -36
View File
@@ -14,6 +14,7 @@ import {
TooltipTrigger,
useTheme,
} from '@umami/react-zen';
import { useRouter } from 'next/navigation';
import { useConfig, useLocale, useLoginQuery, useMessages, useMobile } from '@/components/hooks';
import {
BookText,
@@ -43,11 +44,23 @@ export function UserButton({ showText = true, onClose }: UserButtonProps) {
const { locale, saveLocale } = useLocale();
const { theme, setTheme } = useTheme();
const { isMobile } = useMobile();
const router = useRouter();
const getUrl = (url: string) => {
return cloudMode ? `${process.env.cloudUrl}${url}` : url;
};
const handleNavigate = (url: string, target?: string) => {
onClose?.();
if (target) {
window.open(url, target);
} else if (url.startsWith('http')) {
window.location.href = url;
} else {
router.push(url);
}
};
const languageItems = Object.keys(languages).map(key => ({
value: key,
label: languages[key].label,
@@ -87,33 +100,41 @@ export function UserButton({ showText = true, onClose }: UserButtonProps) {
},
].filter(Boolean);
const trigger = (
<Pressable>
<Row
alignItems="center"
flexGrow={1}
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
role="button"
style={{ cursor: 'pointer', textWrap: 'nowrap', overflow: 'hidden', outline: 'none' }}
>
<Row alignItems="center" gap padding>
<Icon>
<UserCircle />
</Icon>
{showText && <Text>{user.username}</Text>}
</Row>
</Row>
</Pressable>
);
return (
<MenuTrigger>
<TooltipTrigger isDisabled={showText} delay={0}>
<Pressable>
<Row
alignItems="center"
flexGrow={1}
hover={{ backgroundColor: 'surface-sunken' }}
borderRadius
minHeight="40px"
role="button"
style={{ cursor: 'pointer', textWrap: 'nowrap', overflow: 'hidden', outline: 'none' }}
>
<Row alignItems="center" gap padding>
<Icon>
<UserCircle />
</Icon>
{showText && <Text>{user.username}</Text>}
</Row>
</Row>
</Pressable>
<Tooltip placement="right">{user.username}</Tooltip>
</TooltipTrigger>
<Popover placement="top start">
{showText ? (
trigger
) : (
<TooltipTrigger delay={0}>
{trigger}
<Tooltip placement="right">{user.username}</Tooltip>
</TooltipTrigger>
)}
<Popover side="top" align="start">
<Column minWidth="200px">
<Menu autoFocus="last" onAction={onClose}>
<MenuItem id="settings" href={getUrl('/settings')}>
<Menu>
<MenuItem id="settings" onAction={() => handleNavigate(getUrl('/settings'))}>
<Row alignItems="center" gap>
<Icon>
<Settings />
@@ -130,15 +151,18 @@ export function UserButton({ showText = true, onClose }: UserButtonProps) {
<Text>{t(labels.language)}</Text>
</Row>
</MenuItem>
<Popover placement={isMobile ? 'bottom start' : 'right bottom'} isNonModal>
<Popover
side={isMobile ? 'bottom' : 'right'}
align={isMobile ? 'start' : 'end'}
isNonModal
>
<Menu
selectionMode="single"
selectedKeys={new Set([locale])}
onAction={key => saveLocale(key as string)}
style={{ maxHeight: 300, overflow: 'auto' }}
>
{languageItems.map(({ value, label }) => (
<MenuItem key={value} id={value}>
<MenuItem key={value} id={value} onAction={key => saveLocale(key as string)}>
<Text weight={value === locale ? 'bold' : undefined}>{label}</Text>
</MenuItem>
))}
@@ -154,13 +178,13 @@ export function UserButton({ showText = true, onClose }: UserButtonProps) {
<Text>{t(labels.theme)}</Text>
</Row>
</MenuItem>
<Popover placement={isMobile ? 'bottom start' : 'right bottom'} isNonModal>
<Menu
selectionMode="single"
selectedKeys={new Set([theme])}
onAction={key => setTheme(key as 'light' | 'dark')}
>
<MenuItem id="light">
<Popover
side={isMobile ? 'bottom' : 'right'}
align={isMobile ? 'start' : 'end'}
isNonModal
>
<Menu selectionMode="single" selectedKeys={new Set([theme])}>
<MenuItem id="light" onAction={key => setTheme(key as 'light' | 'dark')}>
<Row alignItems="center" gap>
<Icon>
<Sun />
@@ -168,7 +192,7 @@ export function UserButton({ showText = true, onClose }: UserButtonProps) {
<Text>Light</Text>
</Row>
</MenuItem>
<MenuItem id="dark">
<MenuItem id="dark" onAction={key => setTheme(key as 'light' | 'dark')}>
<Row alignItems="center" gap>
<Icon>
<Moon />
@@ -184,7 +208,7 @@ export function UserButton({ showText = true, onClose }: UserButtonProps) {
return <MenuSeparator key={id} />;
}
return (
<MenuItem key={id} id={id} href={path} target={target}>
<MenuItem key={id} id={id} onAction={() => handleNavigate(path, target)}>
<Row alignItems="center" gap>
<Icon>{icon}</Icon>
<Text>{label}</Text>
+1 -1
View File
@@ -48,7 +48,7 @@ export function UserSelect({
allowSearch={true}
searchValue={search}
onSearch={handleSearch}
onChange={handleChange}
onChange={value => handleChange(value as string)}
onOpenChange={handleOpenChange}
maxHeight={480}
listProps={{
+1 -1
View File
@@ -91,7 +91,7 @@ export function WebsiteDateFilter({
<Select
value={compare}
onChange={handleSelect}
style={{ width: 200 }}
buttonProps={{ style: { width: 200 } }}
popoverProps={{ style: { width: 200 } }}
>
<ListItem id="prev">{t(labels.previousPeriod)}</ListItem>
+1 -1
View File
@@ -79,7 +79,7 @@ export function WebsiteSelect({
allowSearch={true}
searchValue={search}
onSearch={handleSearch}
onChange={handleChange}
onChange={value => handleChange(value as string)}
onOpenChange={handleOpenChange}
renderValue={renderValue}
buttonProps={{
+1 -1
View File
@@ -37,7 +37,7 @@ export function DatePickerForm({
return (
<Column gap>
<Row justifyContent="center">
<ToggleGroup disallowEmptySelection value={selected} onChange={setSelected}>
<ToggleGroup value={selected} onChange={setSelected}>
<ToggleGroupItem id={FILTER_DAY}>{t(labels.singleDay)}</ToggleGroupItem>
<ToggleGroupItem id={FILTER_RANGE}>{t(labels.dateRange)}</ToggleGroupItem>
</ToggleGroup>
+27 -18
View File
@@ -1,5 +1,6 @@
import { Focusable, Grid, Row, Text, Tooltip, TooltipTrigger } from '@umami/react-zen';
import { addHours, format, startOfDay } from 'date-fns';
import { Fragment } from 'react';
import { LoadingPanel } from '@/components/common/LoadingPanel';
import { useLocale, useMessages, useWeeklyTrafficQuery } from '@/components/hooks';
import { getDayOfWeekAsDate } from '@/lib/date';
@@ -75,28 +76,36 @@ export function WeeklyTraffic({ websiteId }: { websiteId: string }) {
>
{day?.map((count: number, j) => {
const pct = max ? count / max : 0;
return (
<TooltipTrigger key={j} delay={0} isDisabled={count <= 0}>
<Focusable>
const cell = (
<Focusable>
<Row
alignItems="center"
justifyContent="center"
backgroundColor="surface-raised"
width="16px"
height="16px"
borderRadius="full"
style={{ margin: '0 auto' }}
role="button"
>
<Row
alignItems="center"
justifyContent="center"
backgroundColor="surface-raised"
backgroundColor="primary"
width="16px"
height="16px"
borderRadius="full"
style={{ margin: '0 auto' }}
role="button"
>
<Row
backgroundColor="primary"
width="16px"
height="16px"
borderRadius="full"
style={{ opacity: pct, transform: `scale(${pct})` }}
/>
</Row>
</Focusable>
style={{ opacity: pct, transform: `scale(${pct})` }}
/>
</Row>
</Focusable>
);
if (count <= 0) {
return <Fragment key={j}>{cell}</Fragment>;
}
return (
<TooltipTrigger key={j} delay={0}>
{cell}
<Tooltip
placement="right"
style={{ backgroundColor: 'rgba(0,0,0,0.8)', color: 'white' }}
+13 -6
View File
@@ -1,6 +1,9 @@
'use client';
import { useQueryClient } from '@tanstack/react-query';
import {
AlertBanner,
Alert,
AlertDescription,
AlertTitle,
Box,
Button,
Code,
@@ -14,13 +17,12 @@ import {
TagGroup,
Text,
} from '@umami/react-zen';
import { useQueryClient } from '@tanstack/react-query';
import { ReactNode, useEffect, useState } from 'react';
import { LucideCopy } from 'lucide-react';
import { type ReactNode, useEffect, useState } from 'react';
import { OtpInput } from '@/components/common/OtpInput';
import { useMessages, useUpdateQuery } from '@/components/hooks';
import { TwoFactorSuccessModal } from './TwoFactorSuccessModal';
import styles from './TwoFactorSetupModal.module.css';
import { LucideCopy } from 'lucide-react';
import { TwoFactorSuccessModal } from './TwoFactorSuccessModal';
function Step({
tag,
@@ -187,7 +189,12 @@ export function TwoFactorSetupModal({ required, onClose }: TwoFactorSetupModalPr
</Column>
</Step>
{error && <AlertBanner variant="error" title={t(messages.error)} description={error} />}
{error && (
<Alert variant="danger">
<AlertTitle>{t(messages.error)}</AlertTitle>
<AlertDescription>{error}</AlertDescription>
</Alert>
)}
<Row gap="2" justifyContent="flex-end">
{!required && (
@@ -180,14 +180,11 @@ export function PropertyFilterRecord({
aria-label={filter.propertyName}
items={filteredValues}
inputValue={filter.value}
style={{ width: '100%' }}
onInputChange={v => {
className="w-full"
onInputValueChange={(v: string) => {
setSearch(v);
onChange({ ...filter, value: v });
}}
formValue="text"
allowsEmptyCollection
allowsCustomValue
renderEmptyState={() =>
isLoading ? (
<Loading placement="center" icon="dots" />
@@ -267,7 +264,7 @@ function DateValuePicker({
>
<DateDisplay startDate={selectedDate} endDate={selectedDate} />
</Button>
<Popover placement="bottom start" shouldFlip isNonModal>
<Popover side="bottom" align="start" isNonModal>
<Dialog>
<Column gap>
<Calendar
@@ -39,14 +39,13 @@ export function PropertyFilters({
}) {
const { t, messages } = useMessages();
const { isMobile } = useMobile();
const { data: queriedFields, isLoading, isFetching } = usePropertyFieldsQuery(
source,
websiteId,
eventName,
{
enabled: !providedFields,
},
);
const {
data: queriedFields,
isLoading,
isFetching,
} = usePropertyFieldsQuery(source, websiteId, eventName, {
enabled: !providedFields,
});
const fields = providedFields ?? queriedFields ?? [];
const handleAdd = (propertyName: string) => {
@@ -97,13 +96,14 @@ export function PropertyFilters({
<Plus />
</Icon>
</Button>
<Popover placement="bottom start" shouldFlip>
<Menu
onAction={key => handleAdd(key.toString())}
style={{ maxHeight: 'calc(100vh - 2rem)', overflowY: 'auto' }}
>
<Popover side="bottom" align="start">
<Menu style={{ maxHeight: 'calc(100vh - 2rem)', overflowY: 'auto' }}>
{(fields as any[]).map(field => (
<MenuItem key={`${field.propertyName}:${field.dataType}`} id={field.propertyName}>
<MenuItem
key={`${field.propertyName}:${field.dataType}`}
id={field.propertyName}
onAction={key => handleAdd(key.toString())}
>
{field.propertyName}
</MenuItem>
))}
@@ -118,9 +118,13 @@ export function PropertyFilters({
marginRight="6"
alignSelf="stretch"
>
<List onAction={key => handleAdd(key.toString())}>
<List>
{(fields as any[]).map(field => (
<ListItem key={`${field.propertyName}:${field.dataType}`} id={field.propertyName}>
<ListItem
key={`${field.propertyName}:${field.dataType}`}
id={field.propertyName}
onClick={() => handleAdd(field.propertyName)}
>
{field.propertyName}
</ListItem>
))}
+14 -8
View File
@@ -54,8 +54,8 @@ beforeEach(() => {
vi.mocked(getEntity).mockReset();
vi.mocked(getWebsite).mockReset();
vi.mocked(getTeamUser).mockReset();
vi.mocked(prisma.client.website.findMany).mockReset();
vi.mocked(prisma.client.teamUser.findMany).mockReset();
vi.mocked(prisma.client.website.findMany as (...args: unknown[]) => unknown).mockReset();
vi.mocked(prisma.client.teamUser.findMany as (...args: unknown[]) => unknown).mockReset();
});
describe('canViewWebsite', () => {
@@ -139,12 +139,16 @@ describe('canViewBatchWebsites', () => {
});
test('returns owned, team, and share allowed ids for a user', async () => {
vi.mocked(prisma.client.website.findMany).mockResolvedValue([
vi.mocked(
prisma.client.website.findMany as (...args: unknown[]) => Promise<unknown>,
).mockResolvedValue([
{ id: 'owned', userId: 'user-1', teamId: null },
{ id: 'team', userId: null, teamId: 'team-1' },
{ id: 'foreign', userId: 'other', teamId: null },
] as any);
vi.mocked(prisma.client.teamUser.findMany).mockResolvedValue([{ teamId: 'team-1' }] as any);
vi.mocked(
prisma.client.teamUser.findMany as (...args: unknown[]) => Promise<unknown>,
).mockResolvedValue([{ teamId: 'team-1' }] as any);
await expect(
canViewBatchWebsites({ user: normalUser, shareToken: { websiteId: 'shared' } as any }, [
@@ -157,10 +161,12 @@ describe('canViewBatchWebsites', () => {
});
test('excludes team websites when the user is not a team member', async () => {
vi.mocked(prisma.client.website.findMany).mockResolvedValue([
{ id: 'team', userId: null, teamId: 'team-1' },
] as any);
vi.mocked(prisma.client.teamUser.findMany).mockResolvedValue([] as any);
vi.mocked(
prisma.client.website.findMany as (...args: unknown[]) => Promise<unknown>,
).mockResolvedValue([{ id: 'team', userId: null, teamId: 'team-1' }] as any);
vi.mocked(
prisma.client.teamUser.findMany as (...args: unknown[]) => Promise<unknown>,
).mockResolvedValue([] as any);
await expect(canViewBatchWebsites({ user: normalUser }, ['team'])).resolves.toEqual([]);
});
+1 -1
View File
@@ -45,7 +45,7 @@ function TestProviders({
}) {
return (
<ZenProvider>
<RouterProvider navigate={url => window.history.pushState({}, '', url)}>
<RouterProvider>
<NextIntlClientProvider locale={locale} messages={messages} onError={() => null}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</NextIntlClientProvider>