set monitors to be optional
parent
f983202a96
commit
0369626268
|
|
@ -6,7 +6,7 @@ export default function MaintenanceAlert({
|
||||||
maintenance,
|
maintenance,
|
||||||
style,
|
style,
|
||||||
}: {
|
}: {
|
||||||
maintenance: Omit<MaintenanceConfig, 'monitors'> & { monitors: MonitorTarget[] }
|
maintenance: Omit<MaintenanceConfig, 'monitors'> & { monitors?: MonitorTarget[] }
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -36,7 +36,7 @@ export default function MaintenanceAlert({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Text>{maintenance.body}</Text>
|
<Text>{maintenance.body}</Text>
|
||||||
{maintenance.monitors.length > 0 && (
|
{maintenance.monitors && maintenance.monitors.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<Text mt="xs">
|
<Text mt="xs">
|
||||||
<b>Affected components:</b>
|
<b>Affected components:</b>
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ export default function OverallStatus({
|
||||||
})
|
})
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
let filteredMaintenances: (Omit<MaintenanceConfig, 'monitors'> & { monitors: MonitorTarget[] })[] =
|
let filteredMaintenances: (Omit<MaintenanceConfig, 'monitors'> & { monitors?: MonitorTarget[] })[] =
|
||||||
maintenances
|
maintenances
|
||||||
.filter((m) => now >= new Date(m.start) && (!m.end || now <= new Date(m.end)))
|
.filter((m) => now >= new Date(m.start) && (!m.end || now <= new Date(m.end)))
|
||||||
.map((maintenance) => ({
|
.map((maintenance) => ({
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ export type PageConfig = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MaintenanceConfig = {
|
export type MaintenanceConfig = {
|
||||||
monitors: string[]
|
monitors?: string[]
|
||||||
title?: string
|
title?: string
|
||||||
body: string
|
body: string
|
||||||
start: number | string
|
start: number | string
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ const workerConfig: WorkerConfig = {
|
||||||
// const maintenances: MaintenanceConfig[] = []
|
// const maintenances: MaintenanceConfig[] = []
|
||||||
const maintenances: MaintenanceConfig[] = [
|
const maintenances: MaintenanceConfig[] = [
|
||||||
{
|
{
|
||||||
// Monitor IDs to be affected by this maintenance
|
// [Optional] Monitor IDs to be affected by this maintenance
|
||||||
monitors: ['foo_monitor', 'bar_monitor'],
|
monitors: ['foo_monitor', 'bar_monitor'],
|
||||||
// [Optional] default to "Scheduled Maintenance" if not specified
|
// [Optional] default to "Scheduled Maintenance" if not specified
|
||||||
title: 'Test Maintenance',
|
title: 'Test Maintenance',
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const Worker = {
|
||||||
new Date(timeNow * 1000) >= new Date(m.start) &&
|
new Date(timeNow * 1000) >= new Date(m.start) &&
|
||||||
(!m.end || new Date(timeNow * 1000) <= new Date(m.end))
|
(!m.end || new Date(timeNow * 1000) <= new Date(m.end))
|
||||||
)
|
)
|
||||||
.map((e) => e.monitors)
|
.map((e) => (e.monitors || []))
|
||||||
.flat()
|
.flat()
|
||||||
|
|
||||||
if (maintenanceList.includes(monitor.id)) {
|
if (maintenanceList.includes(monitor.id)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue