From 40ac0ee9a3b63b6fee85866fb3accc556be4b514 Mon Sep 17 00:00:00 2001 From: Moulik Aggarwal Date: Thu, 12 Mar 2026 17:04:31 +0530 Subject: [PATCH] Remove ununsed variable and components (#1970) Signed-off-by: Moulik Aggarwal --- .../(dashboard)/private-locations/page.tsx | 7 +- .../form-status-report.tsx | 2 +- .../rpc/services/status-report/index.ts | 136 +++++++++--------- apps/status-page/src/app/(public)/client.tsx | 51 ------- .../components/status-page/status-events.tsx | 34 +---- .../components/status-page/status-updates.tsx | 22 --- packages/db/src/utils/api-key.test.ts | 2 +- packages/notifications/pagerduty/src/index.ts | 1 - 8 files changed, 71 insertions(+), 184 deletions(-) diff --git a/apps/dashboard/src/app/(dashboard)/private-locations/page.tsx b/apps/dashboard/src/app/(dashboard)/private-locations/page.tsx index 961923e4..445ca7f4 100644 --- a/apps/dashboard/src/app/(dashboard)/private-locations/page.tsx +++ b/apps/dashboard/src/app/(dashboard)/private-locations/page.tsx @@ -1,10 +1,5 @@ -import type { SearchParams } from "nuqs"; import { Client } from "./client"; -export default async function Page({ - searchParams, -}: { - searchParams: Promise; -}) { +export default async function Page() { return ; } diff --git a/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx b/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx index 866d415f..03bbcf70 100644 --- a/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx +++ b/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx @@ -84,7 +84,7 @@ export function FormStatusReportUpdateCard({ index: number; update: StatusReportUpdate; }) { - const { id, reportId } = useParams<{ id: string; reportId: string }>(); + const { reportId } = useParams<{ id: string; reportId: string }>(); const trpc = useTRPC(); const { data: workspace } = useQuery( trpc.workspace.getWorkspace.queryOptions(), diff --git a/apps/server/src/routes/rpc/services/status-report/index.ts b/apps/server/src/routes/rpc/services/status-report/index.ts index bfe37931..07db3a9d 100644 --- a/apps/server/src/routes/rpc/services/status-report/index.ts +++ b/apps/server/src/routes/rpc/services/status-report/index.ts @@ -194,78 +194,76 @@ export const statusReportServiceImpl: ServiceImpl = const date = parseDate(req.date); // Create status report, associations, and initial update in a transaction - const { - report: newReport, - newUpdate, - pageId, - } = await db.transaction(async (tx) => { - // Validate page component IDs inside transaction to prevent TOCTOU race condition - const validatedComponents = await validatePageComponentIds( - req.pageComponentIds, - workspaceId, - tx, - ); - - // Validate that provided pageId matches the components' page - const derivedPageId = validatedComponents.pageId; - const providedPageId = req.pageId?.trim(); - if ( - derivedPageId !== null && - providedPageId && - providedPageId !== "" && - Number(providedPageId) !== derivedPageId - ) { - throw pageIdComponentMismatchError( - providedPageId, - String(derivedPageId), - ); - } - - // Use the derived pageId from components, or parse the provided one - const pageId = - derivedPageId ?? (providedPageId ? Number(providedPageId) : null); - - // Create the status report - const report = await tx - .insert(statusReport) - .values({ + const { report: newReport, newUpdate } = await db.transaction( + async (tx) => { + // Validate page component IDs inside transaction to prevent TOCTOU race condition + const validatedComponents = await validatePageComponentIds( + req.pageComponentIds, workspaceId, - pageId, - title: req.title, - status: protoStatusToDb(req.status), - }) - .returning() - .get(); - - if (!report) { - throw statusReportCreateFailedError(); - } - - // Create page component associations - await updatePageComponentAssociations( - report.id, - validatedComponents.componentIds, - tx, - ); - - // Create the initial update - const newUpdate = await tx - .insert(statusReportUpdate) - .values({ - statusReportId: report.id, - status: protoStatusToDb(req.status), - date, - message: req.message, - }) - .returning() - .get(); + tx, + ); - if (!newUpdate) { - throw statusReportCreateFailedError(); - } + // Validate that provided pageId matches the components' page + const derivedPageId = validatedComponents.pageId; + const providedPageId = req.pageId?.trim(); + if ( + derivedPageId !== null && + providedPageId && + providedPageId !== "" && + Number(providedPageId) !== derivedPageId + ) { + throw pageIdComponentMismatchError( + providedPageId, + String(derivedPageId), + ); + } + + // Use the derived pageId from components, or parse the provided one + const pageId = + derivedPageId ?? (providedPageId ? Number(providedPageId) : null); + + // Create the status report + const report = await tx + .insert(statusReport) + .values({ + workspaceId, + pageId, + title: req.title, + status: protoStatusToDb(req.status), + }) + .returning() + .get(); + + if (!report) { + throw statusReportCreateFailedError(); + } + + // Create page component associations + await updatePageComponentAssociations( + report.id, + validatedComponents.componentIds, + tx, + ); - return { report, newUpdate, pageId }; - }); + // Create the initial update + const newUpdate = await tx + .insert(statusReportUpdate) + .values({ + statusReportId: report.id, + status: protoStatusToDb(req.status), + date, + message: req.message, + }) + .returning() + .get(); + + if (!newUpdate) { + throw statusReportCreateFailedError(); + } + + return { report, newUpdate, pageId }; + }, + ); // Send notifications if requested (outside transaction) if (req.notify) { diff --git a/apps/status-page/src/app/(public)/client.tsx b/apps/status-page/src/app/(public)/client.tsx index bbbc97ae..a11495dc 100644 --- a/apps/status-page/src/app/(public)/client.tsx +++ b/apps/status-page/src/app/(public)/client.tsx @@ -18,15 +18,6 @@ import { StatusTitle, } from "@/components/status-page/status"; import { StatusBanner } from "@/components/status-page/status-banner"; -import { - StatusEvent, - StatusEventAffected, - StatusEventAffectedBadge, - StatusEventContent, - StatusEventDate, - StatusEventTimelineReport, - StatusEventTitle, -} from "@/components/status-page/status-events"; import { StatusMonitor } from "@/components/status-page/status-monitor"; import { ThemePalettePicker } from "@/components/themes/theme-palette-picker"; import { ThemeSelect } from "@/components/themes/theme-select"; @@ -320,45 +311,3 @@ function ThemePlaygroundStatus({ ); } - -// NOTE: we could add a tabs component here to switch between status and events -function ThemePlaygroundEvents({ - className, - ...props -}: React.ComponentProps<"div"> & {}) { - const trpc = useTRPC(); - const { data: report } = useQuery( - trpc.statusPage.getNoopReport.queryOptions(), - ); - const firstUpdate = report?.statusReportUpdates[0]; - - if (!firstUpdate || !report) return null; - - return ( -
- - - - - - {report.title} - - {report.statusReportsToPageComponents.length > 0 ? ( - - {report.statusReportsToPageComponents.map((affected) => ( - - {affected.pageComponent.name} - - ))} - - ) : null} - - - - -
- ); -} diff --git a/apps/status-page/src/components/status-page/status-events.tsx b/apps/status-page/src/components/status-page/status-events.tsx index a0ce375b..5ef261eb 100644 --- a/apps/status-page/src/components/status-page/status-events.tsx +++ b/apps/status-page/src/components/status-page/status-events.tsx @@ -12,8 +12,7 @@ import { } from "@openstatus/ui/components/ui/tooltip"; import { cn } from "@openstatus/ui/lib/utils"; import { formatDistanceStrict } from "date-fns"; -import { Check, ChevronRight } from "lucide-react"; -import Link from "next/link"; +import { Check } from "lucide-react"; import { status } from "./messages"; export function StatusEventGroup({ @@ -291,37 +290,6 @@ export function StatusEventTimelineReportUpdate({ ); } -function StatusEventTimelineReadMore({ - href, - withDot = true, -}: { - href: string; - withDot?: boolean; -}) { - return ( -
-
-
- {withDot ? ( -
-
-
-
-
- ) : null} - - View full report - - -
-
-
- ); -} - export function StatusEventTimelineMaintenance({ maintenance, withDot = true, diff --git a/apps/status-page/src/components/status-page/status-updates.tsx b/apps/status-page/src/components/status-page/status-updates.tsx index fe61ec6d..67b59ab6 100644 --- a/apps/status-page/src/components/status-page/status-updates.tsx +++ b/apps/status-page/src/components/status-page/status-updates.tsx @@ -215,28 +215,6 @@ function CopyInputButton({ ); } -function CopyButton({ - value, - onClick, - ...props -}: React.ComponentProps & { - value: string; -}) { - const { copy, isCopied } = useCopyToClipboard(); - return ( - - ); -} - function SuccessMessage() { return (
diff --git a/packages/db/src/utils/api-key.test.ts b/packages/db/src/utils/api-key.test.ts index 448331a0..f099a299 100644 --- a/packages/db/src/utils/api-key.test.ts +++ b/packages/db/src/utils/api-key.test.ts @@ -9,7 +9,7 @@ import { describe("API Key Utilities", () => { describe("generateApiKey", () => { it("should generate a token with correct format", async () => { - const { token, prefix, hash } = await generateApiKey(); + const { token } = await generateApiKey(); // Token should start with "os_" and be 35 chars total (os_ + 32 hex) expect(token).toMatch(/^os_[a-f0-9]{32}$/); diff --git a/packages/notifications/pagerduty/src/index.ts b/packages/notifications/pagerduty/src/index.ts index f9251e5e..6b946c2a 100644 --- a/packages/notifications/pagerduty/src/index.ts +++ b/packages/notifications/pagerduty/src/index.ts @@ -91,7 +91,6 @@ export const sendDegraded = async ({ export const sendRecovery = async ({ monitor, notification, - incident, }: NotificationContext) => { const data = pagerdutyDataSchema.parse(JSON.parse(notification.data)); -- 2.51.2