Files
accounted/components/ui/empty-state.tsx
T
Mattsson f8db38f989 fix(analytics): mask session replays by default, chrome-only unmask (#1639)
* fix(analytics): mask session replays by default, chrome-only unmask

Invert PostHog session-replay masking from visible-by-default with pattern
masking to deny-by-default: every input value is masked wholesale (rrweb
maskAllInputs, no maskInputFn) and every text node is masked unless it sits
under data-ph-unmask chrome or a table column header (th). Chrome tags live
on the shared UI primitives (PageHeader, Label, Button except combobox
triggers, TabsTrigger, Badge, Card/Dialog/Sheet titles, tooltips, help
popovers, empty states, settings labels), and tagged chrome is still
pattern-scrubbed for amounts and person-/organisationsnummer. data-ph-mask
beats data-ph-unmask, so call sites that interpolate user data into chrome
stay masked; a very-thorough audit swept every unmasked primitive and each
found site got a call-site mask. Confirm-dialog wrappers and toasts stay
masked centrally: their copy describes user objects by design. Untagged new
UI over-masks instead of leaking. Privacy policy, RoPA and decision log
updated in the same change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(analytics): tag detail-section chrome merged from main

The register-detail primitives landed on main after the replay-masking
audit ran: kickers and DefRow labels are static i18n chrome, values stay
masked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(analytics): close skeptic and review findings on replay masking

Explicit data-ph tags now resolve before the th chrome fallback, so a th
nested inside a data-ph-mask container masks correctly (regression test
added). Seven missed text-leak sites get call-site masks: delete-invoice
and credit-page invoice numbers, IB-correction voucher reference, TIC
orgnr (served unnormalized, so the separator-based scrub cannot be relied
on), articles search-term empty state, dimension segment labels, and
activate-account buttons. The attribute channel is closed with rrweb's
blockClass: inputs whose placeholder carries an effective user value
(salary overrides, correction description, danger-zone confirms, credit
confirm) get ph-no-capture, removing the element from recordings while
the prefill UX stays intact; the pivot-th title attribute is dropped.
Privacy-policy effective date bumped to 2026-08-17.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 11:32:45 +02:00

188 lines
4.9 KiB
TypeScript

'use client'
import * as React from 'react'
import Link from 'next/link'
import { useTranslations } from 'next-intl'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import {
ReceiptText,
Users,
ArrowLeftRight,
Building2,
FileText,
Calendar,
Plus,
type LucideIcon,
} from 'lucide-react'
import { SupportLink } from '@/components/ui/support-link'
interface EmptyStateProps {
icon?: LucideIcon
/**
* Usually static i18n strings. The empty state is data-ph-unmask chrome in
* session replays, so a title or description carrying user data (e.g. an
* interpolated search term) must wrap that part in a data-ph-mask element.
*/
title: React.ReactNode
description: React.ReactNode
actionLabel?: string
actionHref?: string
onAction?: () => void
secondaryActionLabel?: string
secondaryActionHref?: string
supportHint?: boolean
className?: string
children?: React.ReactNode
}
/**
* EmptyState: friendly placeholder shown when there is no data.
*/
export function EmptyState({
icon: Icon,
title,
description,
actionLabel,
actionHref,
onAction,
secondaryActionLabel,
secondaryActionHref,
supportHint,
className,
children,
}: EmptyStateProps) {
const t = useTranslations('empty')
return (
// data-ph-unmask: empty states are static i18n chrome in session replays.
<div data-ph-unmask="" className={cn('flex flex-col items-center justify-center py-12 px-4 text-center', className)}>
{Icon && (
<div className="mb-6">
<div className="p-4 rounded-full bg-muted">
<Icon className="h-8 w-8 text-muted-foreground" />
</div>
</div>
)}
<h3 className="text-lg mb-2">{title}</h3>
<p className="text-sm text-muted-foreground max-w-sm mb-6 text-balance">{description}</p>
{supportHint && (
<div className="mb-6">
<SupportLink variant="muted" subject={t('support_hint_subject')}>
{t('support_hint_label')}
</SupportLink>
</div>
)}
{(actionLabel || children) && (
<div className="flex flex-col sm:flex-row items-center gap-3">
{actionHref && actionLabel && (
<Link href={actionHref}>
<Button>
<Plus className="mr-2 h-4 w-4" />
{actionLabel}
</Button>
</Link>
)}
{onAction && actionLabel && (
<Button onClick={onAction}>
<Plus className="mr-2 h-4 w-4" />
{actionLabel}
</Button>
)}
{secondaryActionHref && secondaryActionLabel && (
<Link href={secondaryActionHref}>
<Button variant="outline">{secondaryActionLabel}</Button>
</Link>
)}
{children}
</div>
)}
</div>
)
}
// Preset empty states for common pages
export function EmptyInvoices({ onAction }: { onAction?: () => void } = {}) {
const t = useTranslations('empty')
return (
<EmptyState
icon={ReceiptText}
title={t('preset_invoices_title')}
description={t('preset_invoices_description')}
actionLabel={t('preset_invoices_action')}
actionHref={onAction ? undefined : '/invoices?new=1'}
onAction={onAction}
/>
)
}
export function EmptyCustomers({ onAction }: { onAction?: () => void } = {}) {
const t = useTranslations('empty')
return (
<EmptyState
icon={Users}
title={t('preset_customers_title')}
description={t('preset_customers_description')}
actionLabel={t('preset_customers_action')}
actionHref={onAction ? undefined : '/customers/new'}
onAction={onAction}
/>
)
}
export function EmptyTransactions() {
const t = useTranslations('empty')
return (
<EmptyState
icon={ArrowLeftRight}
title={t('preset_transactions_title')}
description={t('preset_transactions_description')}
actionLabel={t('preset_transactions_action')}
actionHref="/import"
supportHint
/>
)
}
export function EmptyDeadlines() {
const t = useTranslations('empty')
return (
<EmptyState
icon={Calendar}
title={t('preset_deadlines_title')}
description={t('preset_deadlines_description')}
/>
)
}
export function NoBankConnected() {
const t = useTranslations('empty')
return (
<EmptyState
icon={Building2}
title={t('preset_no_bank_title')}
description={t('preset_no_bank_description')}
actionLabel={t('preset_no_bank_action')}
actionHref="/import"
supportHint
/>
)
}
export function EmptyReports() {
const t = useTranslations('empty')
return (
<EmptyState
icon={FileText}
title={t('preset_reports_title')}
description={t('preset_reports_description')}
actionLabel={t('preset_reports_action')}
actionHref="/invoices?new=1"
secondaryActionLabel={t('preset_reports_secondary')}
secondaryActionHref="/import"
/>
)
}