* feat: move types * feat: add maintenance alert * feat: move to config/base class to have fallback values on missing exports * fix: wrong import for types * Revert "fix: wrong import for types" This reverts commit ca2b2e3a68464cfa1b4aef4d99978de02591df74. * Revert "feat: move to config/base class to have fallback values on missing exports" This reverts commit 9932ea2590193aabd248fbba6b2c3a215da45d18. * fix: imports * chore: formatting * fix: handle filtering for global status * fix: pass props * fix: ignore active maintenances when sending notifications * fix: mark as warning when monitor is in maintenance * fix: title width & warning icon * fix: remove accordeons again * alert config/style changes, worker code improve * update example config * update example config * set monitors to be optional --------- Co-authored-by: lyc8503 <[email protected]>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { Alert, List, Text } from '@mantine/core'
|
|
import { IconAlertTriangle } from '@tabler/icons-react'
|
|
import { MaintenanceConfig, MonitorTarget } from '@/types/config'
|
|
|
|
export default function MaintenanceAlert({
|
|
maintenance,
|
|
style,
|
|
}: {
|
|
maintenance: Omit<MaintenanceConfig, 'monitors'> & { monitors?: MonitorTarget[] }
|
|
style?: React.CSSProperties
|
|
}) {
|
|
return (
|
|
<Alert
|
|
icon={<IconAlertTriangle />}
|
|
title={maintenance.title || 'Scheduled Maintenance'}
|
|
color={maintenance.color || 'yellow'}
|
|
withCloseButton={false}
|
|
style={{ position: 'relative', margin: '16px auto 0 auto', ...style }}
|
|
>
|
|
{/* Date range in top right */}
|
|
<div
|
|
style={{
|
|
position: 'absolute',
|
|
top: 10,
|
|
right: 10,
|
|
fontSize: '0.85rem',
|
|
textAlign: 'right',
|
|
padding: '2px 8px',
|
|
borderRadius: 6,
|
|
}}
|
|
>
|
|
<b>From:</b> {new Date(maintenance.start).toLocaleString()}
|
|
<br />
|
|
<b>To:</b>{' '}
|
|
{maintenance.end ? new Date(maintenance.end).toLocaleString() : 'Until further notice'}
|
|
</div>
|
|
|
|
<Text>{maintenance.body}</Text>
|
|
{maintenance.monitors && maintenance.monitors.length > 0 && (
|
|
<>
|
|
<Text mt="xs">
|
|
<b>Affected components:</b>
|
|
</Text>
|
|
<List size="sm" withPadding>
|
|
{maintenance.monitors.map((comp, compIdx) => (
|
|
<List.Item key={compIdx}>{comp.name}</List.Item>
|
|
))}
|
|
</List>
|
|
</>
|
|
)}
|
|
</Alert>
|
|
)
|
|
}
|