Upcoming and active maintenance (#142)
* Updated with intial commit - MaintenanceAlert.tsx now handles upcoming and active maintenance alerts. - OverallStatus.tsx updated to include collapsible sections for ongoing and upcoming maintenance alerts. * Updated MaintenanceAlert layout for better responsiveness * Revert the uptime.config.ts * fix: Added type definitions for active and upcoming maintenances * Update components/MaintenanceAlert.tsx Co-authored-by: Bennet Gallein <[email protected]> * Update: added `pageConfig.maintenances.upcomingColor` to control upcoming maintenance alert colors. * Feature: Added a config option for the favicon. * keep original styles * remove collapse * add back a different collapse for upcoming events * css grid to align date text * tiny css changes and cleanup --------- Co-authored-by: Bennet Gallein <[email protected]> Co-authored-by: lyc8503 <[email protected]>
This commit is contained in:
6 files changed
+87
-16
No files matched your search
@@ -2,13 +2,16 @@ import { Alert, List, Text, useMantineTheme } from '@mantine/core'
|
||||
import { useMediaQuery } from '@mantine/hooks'
|
||||
import { IconAlertTriangle } from '@tabler/icons-react'
|
||||
import { MaintenanceConfig, MonitorTarget } from '@/types/config'
|
||||
import { pageConfig } from '@/uptime.config'
|
||||
|
||||
export default function MaintenanceAlert({
|
||||
maintenance,
|
||||
style,
|
||||
upcoming = false,
|
||||
}: {
|
||||
maintenance: Omit<MaintenanceConfig, 'monitors'> & { monitors?: MonitorTarget[] }
|
||||
style?: React.CSSProperties
|
||||
upcoming?: boolean
|
||||
}) {
|
||||
const theme = useMantineTheme()
|
||||
const isDesktop = useMediaQuery(`(min-width: ${theme.breakpoints.sm})`)
|
||||
@@ -23,12 +26,14 @@ export default function MaintenanceAlert({
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{maintenance.title || 'Scheduled Maintenance'}
|
||||
{(upcoming ? '[Upcoming] ' : '') + (maintenance.title || 'Scheduled Maintenance')}
|
||||
</span>
|
||||
}
|
||||
color={maintenance.color || 'yellow'}
|
||||
color={
|
||||
upcoming ? pageConfig.maintenances?.upcomingColor ?? 'gray' : maintenance.color || 'yellow'
|
||||
}
|
||||
withCloseButton={false}
|
||||
style={{ position: 'relative', margin: '16px auto 0 auto', ...style }}
|
||||
style={{ margin: '16px auto 0 auto', ...style }}
|
||||
>
|
||||
{/* Date range in top right (desktop) or inline (mobile) */}
|
||||
<div
|
||||
@@ -45,16 +50,30 @@ export default function MaintenanceAlert({
|
||||
padding: '2px 8px',
|
||||
textAlign: 'right',
|
||||
}
|
||||
: {}),
|
||||
: { marginBottom: 4 }),
|
||||
}}
|
||||
>
|
||||
<b>From:</b> {new Date(maintenance.start).toLocaleString()}
|
||||
<br />
|
||||
<b>To:</b>{' '}
|
||||
{maintenance.end ? new Date(maintenance.end).toLocaleString() : 'Until further notice'}
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'auto 1fr',
|
||||
gridColumnGap: '3px',
|
||||
}}
|
||||
>
|
||||
<div style={{ textAlign: 'right', fontWeight: 'bold' }}>
|
||||
{upcoming ? 'Scheduled for:' : 'From:'}
|
||||
</div>
|
||||
<div>{new Date(maintenance.start).toLocaleString()}</div>
|
||||
<div style={{ textAlign: 'right', fontWeight: 'bold' }}>
|
||||
{upcoming ? 'Expected end:' : 'To:'}
|
||||
</div>
|
||||
<div>
|
||||
{maintenance.end ? new Date(maintenance.end).toLocaleString() : 'Until further notice'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Text style={{ paddingTop: '3px' }}>{maintenance.body}</Text>
|
||||
<Text style={{ paddingTop: '3px', whiteSpace: 'pre-line' }}>{maintenance.body}</Text>
|
||||
{maintenance.monitors && maintenance.monitors.length > 0 && (
|
||||
<>
|
||||
<Text mt="xs">
|
||||
|
||||
Reference in new issue
Block a user