Skip to content

Commit 2295266

Browse files
committed
Remove ununsed variable and components
Signed-off-by: Moulik Aggarwal <qwertymoulik@gmail.com>
1 parent a93c18d commit 2295266

File tree

8 files changed

+71
-184
lines changed

8 files changed

+71
-184
lines changed
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import type { SearchParams } from "nuqs";
21
import { Client } from "./client";
32

4-
export default async function Page({
5-
searchParams,
6-
}: {
7-
searchParams: Promise<SearchParams>;
8-
}) {
3+
export default async function Page() {
94
return <Client />;
105
}

apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function FormStatusReportUpdateCard({
8484
index: number;
8585
update: StatusReportUpdate;
8686
}) {
87-
const { id, reportId } = useParams<{ id: string; reportId: string }>();
87+
const { reportId } = useParams<{ id: string; reportId: string }>();
8888
const trpc = useTRPC();
8989
const { data: workspace } = useQuery(
9090
trpc.workspace.getWorkspace.queryOptions(),

apps/server/src/routes/rpc/services/status-report/index.ts

Lines changed: 67 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -194,78 +194,76 @@ export const statusReportServiceImpl: ServiceImpl<typeof StatusReportService> =
194194
const date = parseDate(req.date);
195195

196196
// Create status report, associations, and initial update in a transaction
197-
const {
198-
report: newReport,
199-
newUpdate,
200-
pageId,
201-
} = await db.transaction(async (tx) => {
202-
// Validate page component IDs inside transaction to prevent TOCTOU race condition
203-
const validatedComponents = await validatePageComponentIds(
204-
req.pageComponentIds,
205-
workspaceId,
206-
tx,
207-
);
208-
209-
// Validate that provided pageId matches the components' page
210-
const derivedPageId = validatedComponents.pageId;
211-
const providedPageId = req.pageId?.trim();
212-
if (
213-
derivedPageId !== null &&
214-
providedPageId &&
215-
providedPageId !== "" &&
216-
Number(providedPageId) !== derivedPageId
217-
) {
218-
throw pageIdComponentMismatchError(
219-
providedPageId,
220-
String(derivedPageId),
221-
);
222-
}
223-
224-
// Use the derived pageId from components, or parse the provided one
225-
const pageId =
226-
derivedPageId ?? (providedPageId ? Number(providedPageId) : null);
227-
228-
// Create the status report
229-
const report = await tx
230-
.insert(statusReport)
231-
.values({
197+
const { report: newReport, newUpdate } = await db.transaction(
198+
async (tx) => {
199+
// Validate page component IDs inside transaction to prevent TOCTOU race condition
200+
const validatedComponents = await validatePageComponentIds(
201+
req.pageComponentIds,
232202
workspaceId,
233-
pageId,
234-
title: req.title,
235-
status: protoStatusToDb(req.status),
236-
})
237-
.returning()
238-
.get();
239-
240-
if (!report) {
241-
throw statusReportCreateFailedError();
242-
}
243-
244-
// Create page component associations
245-
await updatePageComponentAssociations(
246-
report.id,
247-
validatedComponents.componentIds,
248-
tx,
249-
);
250-
251-
// Create the initial update
252-
const newUpdate = await tx
253-
.insert(statusReportUpdate)
254-
.values({
255-
statusReportId: report.id,
256-
status: protoStatusToDb(req.status),
257-
date,
258-
message: req.message,
259-
})
260-
.returning()
261-
.get();
203+
tx,
204+
);
262205

263-
if (!newUpdate) {
264-
throw statusReportCreateFailedError();
265-
}
206+
// Validate that provided pageId matches the components' page
207+
const derivedPageId = validatedComponents.pageId;
208+
const providedPageId = req.pageId?.trim();
209+
if (
210+
derivedPageId !== null &&
211+
providedPageId &&
212+
providedPageId !== "" &&
213+
Number(providedPageId) !== derivedPageId
214+
) {
215+
throw pageIdComponentMismatchError(
216+
providedPageId,
217+
String(derivedPageId),
218+
);
219+
}
220+
221+
// Use the derived pageId from components, or parse the provided one
222+
const pageId =
223+
derivedPageId ?? (providedPageId ? Number(providedPageId) : null);
224+
225+
// Create the status report
226+
const report = await tx
227+
.insert(statusReport)
228+
.values({
229+
workspaceId,
230+
pageId,
231+
title: req.title,
232+
status: protoStatusToDb(req.status),
233+
})
234+
.returning()
235+
.get();
236+
237+
if (!report) {
238+
throw statusReportCreateFailedError();
239+
}
240+
241+
// Create page component associations
242+
await updatePageComponentAssociations(
243+
report.id,
244+
validatedComponents.componentIds,
245+
tx,
246+
);
266247

267-
return { report, newUpdate, pageId };
268-
});
248+
// Create the initial update
249+
const newUpdate = await tx
250+
.insert(statusReportUpdate)
251+
.values({
252+
statusReportId: report.id,
253+
status: protoStatusToDb(req.status),
254+
date,
255+
message: req.message,
256+
})
257+
.returning()
258+
.get();
259+
260+
if (!newUpdate) {
261+
throw statusReportCreateFailedError();
262+
}
263+
264+
return { report, newUpdate, pageId };
265+
},
266+
);
269267

270268
// Send notifications if requested (outside transaction)
271269
if (req.notify) {

apps/status-page/src/app/(public)/client.tsx

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ import {
1818
StatusTitle,
1919
} from "@/components/status-page/status";
2020
import { StatusBanner } from "@/components/status-page/status-banner";
21-
import {
22-
StatusEvent,
23-
StatusEventAffected,
24-
StatusEventAffectedBadge,
25-
StatusEventContent,
26-
StatusEventDate,
27-
StatusEventTimelineReport,
28-
StatusEventTitle,
29-
} from "@/components/status-page/status-events";
3021
import { StatusMonitor } from "@/components/status-page/status-monitor";
3122
import { ThemePalettePicker } from "@/components/themes/theme-palette-picker";
3223
import { ThemeSelect } from "@/components/themes/theme-select";
@@ -320,45 +311,3 @@ function ThemePlaygroundStatus({
320311
</div>
321312
);
322313
}
323-
324-
// NOTE: we could add a tabs component here to switch between status and events
325-
function ThemePlaygroundEvents({
326-
className,
327-
...props
328-
}: React.ComponentProps<"div"> & {}) {
329-
const trpc = useTRPC();
330-
const { data: report } = useQuery(
331-
trpc.statusPage.getNoopReport.queryOptions(),
332-
);
333-
const firstUpdate = report?.statusReportUpdates[0];
334-
335-
if (!firstUpdate || !report) return null;
336-
337-
return (
338-
<div className={cn("h-full w-full", className)} {...props}>
339-
<Status variant="success">
340-
<StatusEvent>
341-
<StatusEventDate date={firstUpdate.date} className="lg:flex-row" />
342-
<StatusEventContent hoverable={false}>
343-
<StatusEventTitle className="inline-flex gap-1">
344-
{report.title}
345-
</StatusEventTitle>
346-
{report.statusReportsToPageComponents.length > 0 ? (
347-
<StatusEventAffected>
348-
{report.statusReportsToPageComponents.map((affected) => (
349-
<StatusEventAffectedBadge key={affected.pageComponent.id}>
350-
{affected.pageComponent.name}
351-
</StatusEventAffectedBadge>
352-
))}
353-
</StatusEventAffected>
354-
) : null}
355-
<StatusEventTimelineReport
356-
updates={report.statusReportUpdates}
357-
reportId={report.id}
358-
/>
359-
</StatusEventContent>
360-
</StatusEvent>
361-
</Status>
362-
</div>
363-
);
364-
}

apps/status-page/src/components/status-page/status-events.tsx

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
} from "@openstatus/ui/components/ui/tooltip";
1313
import { cn } from "@openstatus/ui/lib/utils";
1414
import { formatDistanceStrict } from "date-fns";
15-
import { Check, ChevronRight } from "lucide-react";
16-
import Link from "next/link";
15+
import { Check } from "lucide-react";
1716
import { status } from "./messages";
1817

1918
export function StatusEventGroup({
@@ -291,37 +290,6 @@ export function StatusEventTimelineReportUpdate({
291290
);
292291
}
293292

294-
function StatusEventTimelineReadMore({
295-
href,
296-
withDot = true,
297-
}: {
298-
href: string;
299-
withDot?: boolean;
300-
}) {
301-
return (
302-
<div className="group">
303-
<div className="flex flex-row items-center justify-between gap-2">
304-
<div className="flex flex-row gap-4">
305-
{withDot ? (
306-
<div className="flex flex-col">
307-
<div className="flex h-5 flex-col items-center justify-center">
308-
<div className="size-2.5 shrink-0 rounded-full bg-muted" />
309-
</div>
310-
</div>
311-
) : null}
312-
<Link
313-
href={href}
314-
className="flex items-center gap-1 font-medium text-muted-foreground text-sm hover:text-foreground hover:underline"
315-
>
316-
View full report
317-
<ChevronRight className="size-4" />
318-
</Link>
319-
</div>
320-
</div>
321-
</div>
322-
);
323-
}
324-
325293
export function StatusEventTimelineMaintenance({
326294
maintenance,
327295
withDot = true,

apps/status-page/src/components/status-page/status-updates.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -215,28 +215,6 @@ function CopyInputButton({
215215
);
216216
}
217217

218-
function CopyButton({
219-
value,
220-
onClick,
221-
...props
222-
}: React.ComponentProps<typeof Button> & {
223-
value: string;
224-
}) {
225-
const { copy, isCopied } = useCopyToClipboard();
226-
return (
227-
<Button
228-
size="sm"
229-
onClick={(e) => {
230-
copy(value, { withToast: true });
231-
onClick?.(e);
232-
}}
233-
{...props}
234-
>
235-
{isCopied ? "Copied" : "Copy"}
236-
</Button>
237-
);
238-
}
239-
240218
function SuccessMessage() {
241219
return (
242220
<div className="flex flex-col items-center justify-center gap-1 p-3">

packages/db/src/utils/api-key.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
describe("API Key Utilities", () => {
1010
describe("generateApiKey", () => {
1111
it("should generate a token with correct format", async () => {
12-
const { token, prefix, hash } = await generateApiKey();
12+
const { token } = await generateApiKey();
1313

1414
// Token should start with "os_" and be 35 chars total (os_ + 32 hex)
1515
expect(token).toMatch(/^os_[a-f0-9]{32}$/);

packages/notifications/pagerduty/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export const sendDegraded = async ({
9191
export const sendRecovery = async ({
9292
monitor,
9393
notification,
94-
incident,
9594
}: NotificationContext) => {
9695
const data = pagerdutyDataSchema.parse(JSON.parse(notification.data));
9796

0 commit comments

Comments
 (0)