The page (pages/, components/, styles/) is rewritten in Cottage's brand, replacing Mantine. - Brand files: tokens, fonts and component CSS copied from Hearth; logo, pod row, status pill and banner ported from the brand handbook. - Themes: light by default, dark when the OS asks. - Services: grouped; each has a status pill, uptime and 90 daily bars (30 on phones). - Bars: each bar has a text label, keyboard navigation and a day card. - Response-time chart: optional, drawn in brand colours. - Notices: colour-coded posted notices and planned maintenance. - Incident history: by month, with the brand's empty state. The check worker, D1 storage, types and Terraform are untouched, so upstream merges stay clean. uptime.config.ts lists Cottage's services (website, dashboard, apps in US East). `npm run dev` shows sample data (?sample=outage|maintenance|empty) since there's no D1. Deploys are gated on the CLOUDFLARE_DEPLOY repository variable until launch, Wrangler telemetry is off, and a Check workflow lints, type-checks and builds every pull request. Removed upstream's issue-translation workflow, funding file and translations.
82 lines
3.1 KiB
TypeScript
82 lines
3.1 KiB
TypeScript
import Head from 'next/head'
|
|
import Link from 'next/link'
|
|
import { MaintenanceConfig, MonitorTarget } from '@/types/config'
|
|
import { maintenances as configMaintenances, pageConfig } from '@/uptime.config'
|
|
import OverallStatus from '@/components/OverallStatus'
|
|
import Header from '@/components/Header'
|
|
import MonitorList from '@/components/MonitorList'
|
|
import Footer from '@/components/Footer'
|
|
import UptimeBars from '@/components/UptimeBars'
|
|
import { CompactedMonitorStateWrapper, getFromStore } from '@/worker/src/store'
|
|
|
|
export const runtime = 'experimental-edge'
|
|
|
|
export default function Home({
|
|
compactedStateStr,
|
|
monitors,
|
|
maintenances,
|
|
}: {
|
|
compactedStateStr: string | null
|
|
monitors: MonitorTarget[]
|
|
maintenances: MaintenanceConfig[]
|
|
}) {
|
|
const state = new CompactedMonitorStateWrapper(compactedStateStr).uncompact()
|
|
|
|
// #monitor-id shows one service's bars on its own (for embedding in an iframe).
|
|
const monitorId = window.location.hash.substring(1)
|
|
if (monitorId) {
|
|
const monitor = monitors.find((m) => m.id === monitorId)
|
|
return (
|
|
<main className="st-embed">
|
|
{monitor && state.incident[monitor.id] ? (
|
|
<UptimeBars monitor={monitor} state={state} />
|
|
) : (
|
|
<p>No service called “{monitorId}”.</p>
|
|
)}
|
|
</main>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>{pageConfig.title}</title>
|
|
<meta name="description" content="Live status of Cottage's website, dashboard and app hosting, checked every minute." />
|
|
</Head>
|
|
<Header current="status" />
|
|
<main className="st-main">
|
|
<div className="st-container st-container--narrow">
|
|
<OverallStatus state={state} monitors={monitors} maintenances={maintenances} />
|
|
<MonitorList monitors={monitors} state={state} maintenances={maintenances} />
|
|
<p className="st-note">
|
|
Uptime covers the last 90 days. Planned maintenance and incident updates are listed under{' '}
|
|
<Link href="/incidents">Incident history</Link>.
|
|
</p>
|
|
</div>
|
|
</main>
|
|
<Footer />
|
|
</>
|
|
)
|
|
}
|
|
|
|
export async function getServerSideProps({ query }: { query: Record<string, string | string[] | undefined> }) {
|
|
const { workerConfig } = await import('@/uptime.config')
|
|
const monitors = workerConfig.monitors.map((m) => ({
|
|
id: m.id,
|
|
name: m.name,
|
|
tooltip: m.tooltip ?? null,
|
|
statusPageLink: m.statusPageLink ?? null,
|
|
hideLatencyChart: m.hideLatencyChart ?? null,
|
|
}))
|
|
|
|
// `npm run dev` has no D1 database: show sample data instead (dev/sample.ts).
|
|
if (process.env.NODE_ENV === 'development' && !(process.env as any).UPTIMEFLARE_D1) {
|
|
const { sampleState, sampleNotices } = await import('@/dev/sample')
|
|
return { props: { compactedStateStr: sampleState(workerConfig.monitors, String(query.sample ?? '')), monitors, maintenances: sampleNotices(String(query.sample ?? '')) } }
|
|
}
|
|
|
|
// Read the state as a string, so the server stays inside its CPU limit.
|
|
const compactedStateStr = await getFromStore(process.env as any, 'state')
|
|
return { props: { compactedStateStr, monitors, maintenances: configMaintenances } }
|
|
}
|