hyperdx/packages/app/src/components/Error/ErrorCollapse.tsx
Brandon Pereira 0bfec14830
[HDX-3981] Upgrade Mantine v7 to v9 (#2096)
## Summary

Upgrade all `@mantine/*` packages from v7.17.8 to v9.0.0 (skipping the v8 intermediate step since the breaking changes were manageable in a single pass). This improves React 19 compatibility and keeps the UI library current.

### Breaking changes resolved

**v7 → v8 changes:**
- `DateTimePicker`/`DateInput` `onChange` now returns a date string instead of a `Date` object — updated handlers in `AlertScheduleFields.tsx` and `SourceForm.tsx`
- Updated `postcss-preset-mantine` to ^1.18.0

**v8 → v9 changes:**
- `Collapse`: renamed `in` prop to `expanded` (11 instances across 10 files)
- `Grid`: removed deprecated `overflow="hidden"` prop (5 instances, 3 files) — v9 uses native CSS `gap` instead of negative margins
- `Text`/`Anchor`: renamed `color` prop to `c` style prop (7 instances, 5 files)
- `SourceSchemaPreview`: replaced removed `TextProps` `color` key with `React.CSSProperties`
- Theme: set `defaultRadius: 'sm'` in both theme configs to preserve existing visual appearance (v9 changed default from `sm` to `md`)
- Updated test for Collapse visibility behavior change in jsdom

### Not affected (verified)
- No `@mantine/carousel` or `@mantine/tiptap` usage — embla and Tiptap migrations not needed
- No `TypographyStylesProvider`, `Spoiler`, `positionDependencies`, `useFullscreen`, `useMouse`, `useMutationObserver`, or `zodResolver` from `@mantine/form` usage
- All `useLocalStorage` calls from `@mantine/hooks` already provide `defaultValue`
- `react-hook-form-mantine` has a peer dep mismatch (expects `@mantine/core ^7.0.0`) but its thin wrappers are compatible at runtime

### How to test locally or on Vercel

1. Start the dev stack with `yarn dev`
2. Navigate through key pages: search, dashboards, alerts, services dashboard, Kubernetes pages
3. Verify Collapse animations work correctly (alert details, nav sub-menus, advanced settings)
4. Verify Grid layouts render properly on services dashboard side panels
5. Verify no visual regressions in border-radius, spacing, or color across components

### References

- Linear Issue: https://linear.app/clickhouse/issue/HDX-3981/upgrade-mantine-v7-v9
- [Mantine v9 Changelog](https://mantine.dev/changelog/9-0-0/)
- [7.x → 8.x Migration Guide](https://mantine.dev/guides/7x-to-8x/)
- [8.x → 9.x Migration Guide](https://mantine.dev/guides/8x-to-9x/)
2026-04-13 16:03:29 +00:00

45 lines
1.1 KiB
TypeScript

import { useState } from 'react';
import { Button, Code, Collapse } from '@mantine/core';
import { IconAlertTriangle, IconChevronRight } from '@tabler/icons-react';
type ErrorCollapseProps = {
summary: string;
details: React.ReactNode;
};
export function ErrorCollapse({ summary, details }: ErrorCollapseProps) {
const [open, setOpen] = useState(false);
return (
<>
<Button
variant="subtle"
size="compact-xs"
color="red"
onClick={() => setOpen(o => !o)}
leftSection={
<IconChevronRight
size={14}
style={{
transform: open ? 'rotate(90deg)' : 'rotate(0deg)',
transition: 'transform 150ms ease',
}}
/>
}
>
<IconAlertTriangle size={14} className="me-2" /> {summary}
</Button>
<Collapse expanded={open}>
<Code
block
c="red"
mt="xs"
style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}
>
{details}
</Code>
</Collapse>
</>
);
}