feat: remove hash

pull/113/head
lyc8503 2025-09-20 22:56:26 +08:00
parent 16ef9bf3e7
commit 62bca079cb
2 changed files with 43 additions and 61 deletions

View File

@ -5,70 +5,57 @@ import { MaintenanceConfig, MonitorTarget } from '@/types/config'
export default function MaintenanceAlert({
maintenance,
style,
hash,
}: {
maintenance: Omit<MaintenanceConfig, 'monitors'> & { monitors?: MonitorTarget[] }
style?: React.CSSProperties
hash?: string
}) {
const titleStyle: React.CSSProperties = {}
if (hash) {
titleStyle['textDecoration'] = 'underline'
titleStyle['cursor'] = 'pointer'
}
function updateHash() {
if (!hash) return
window.location.hash = hash
}
return (
<div id={hash}>
<Alert
icon={<IconAlertTriangle />}
title={
(
<span style={titleStyle} onClick={updateHash}>
{maintenance.title || 'Scheduled Maintenance'}
</span>
)
}
color={maintenance.color || 'yellow'}
withCloseButton={false}
style={{ position: 'relative', margin: '16px auto 0 auto', ...style }}
<Alert
icon={<IconAlertTriangle />}
title={
(
<span style={titleStyle}>
{maintenance.title || 'Scheduled Maintenance'}
</span>
)
}
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,
}}
>
{/* 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>
<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>
</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>
)
}

View File

@ -119,11 +119,6 @@ export default function IncidentsPage() {
monitorFilteredIncidents.map((incident, i) => (
<MaintenanceAlert
key={i}
hash={[
new Date(incident.start).getFullYear(),
String(new Date(incident.start).getMonth() + 1).padStart(2, '0'),
monitorFilteredIncidents.length - i,
].join('-')}
maintenance={incident}
/>
))