mirror of
https://github.com/Dvorinka/Dash.git
synced 2026-10-28 15:51:27 +00:00
fix: byte formatting + exactOptionalPropertyTypes
fmtBytes used 1<<40 — a 32-bit shift in JS evaluates to 1<<8=256, so every value >=256 bytes rendered as TB. Also drop undefined-valued props that exactOptionalPropertyTypes rejects in incident/status-page bodies. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
c84a4be876
commit
97b8f5e87f
4 files changed
+16
-6
No files matched your search
@@ -23,3 +23,4 @@ coverage/
|
|||||||
|
|
||||||
# local tooling artifacts
|
# local tooling artifacts
|
||||||
.playwright-mcp/
|
.playwright-mcp/
|
||||||
|
.playwright-cli/
|
||||||
@@ -54,7 +54,9 @@ export function IncidentsPage() {
|
|||||||
// The select only offers the three severities, but its value is a
|
// The select only offers the three severities, but its value is a
|
||||||
// plain string — narrow at the boundary instead of asserting.
|
// plain string — narrow at the boundary instead of asserting.
|
||||||
const severity = sev === "critical" || sev === "minor" ? sev : "major";
|
const severity = sev === "critical" || sev === "minor" ? sev : "major";
|
||||||
await api.POST("/api/incidents", { body: { title: title.trim(), severity, message: msg || undefined } });
|
await api.POST("/api/incidents", {
|
||||||
|
body: { title: title.trim(), severity, ...(msg.trim() ? { message: msg.trim() } : {}) },
|
||||||
|
});
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
setDlgOpen(false);
|
setDlgOpen(false);
|
||||||
setTitle(""); setMsg("");
|
setTitle(""); setMsg("");
|
||||||
@@ -63,7 +65,10 @@ export function IncidentsPage() {
|
|||||||
|
|
||||||
async function transition(id: string | undefined, to: Status, message?: string) {
|
async function transition(id: string | undefined, to: Status, message?: string) {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
await api.PATCH("/api/incidents/{id}", { params: { path: { id } }, body: { status: to, message } });
|
await api.PATCH("/api/incidents/{id}", {
|
||||||
|
params: { path: { id } },
|
||||||
|
body: { status: to, ...(message?.trim() ? { message } : {}) },
|
||||||
|
});
|
||||||
await load();
|
await load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export function StatusPagesPage() {
|
|||||||
const { error } = await api.POST("/api/status-pages", {
|
const { error } = await api.POST("/api/status-pages", {
|
||||||
body: {
|
body: {
|
||||||
title: pTitle.trim(),
|
title: pTitle.trim(),
|
||||||
slug: pSlug.trim() || undefined,
|
...(pSlug.trim() ? { slug: pSlug.trim() } : {}),
|
||||||
description: pDesc.trim(),
|
description: pDesc.trim(),
|
||||||
monitorIds: pMonitors,
|
monitorIds: pMonitors,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,10 +11,14 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const TB = 2 ** 40;
|
||||||
|
const GB = 2 ** 30;
|
||||||
|
const MB = 2 ** 20;
|
||||||
|
|
||||||
export function fmtBytes(b: number) {
|
export function fmtBytes(b: number) {
|
||||||
if (b >= 1 << 40) return `${(b / (1 << 40)).toFixed(1)} TB`;
|
if (b >= TB) return `${(b / TB).toFixed(1)} TB`;
|
||||||
if (b >= 1 << 30) return `${(b / (1 << 30)).toFixed(1)} GB`;
|
if (b >= GB) return `${(b / GB).toFixed(1)} GB`;
|
||||||
return `${(b / (1 << 20)).toFixed(0)} MB`;
|
return `${(b / MB).toFixed(0)} MB`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fmtUptime(s: number) {
|
export function fmtUptime(s: number) {
|
||||||
|
|||||||
Reference in new issue
Block a user