Working on ui

This commit is contained in:
Owen
2026-04-16 16:30:28 -07:00
parent a9d68bd0cf
commit c4308aaa69
3 changed files with 39 additions and 20 deletions

View File

@@ -186,6 +186,9 @@ export function HealthCheckCredenza(props: HealthCheckCredenzaProps) {
defaultValues: mode === "submit" ? DEFAULT_VALUES : {} defaultValues: mode === "submit" ? DEFAULT_VALUES : {}
}); });
const watchedEnabled = form.watch("hcEnabled");
const watchedMode = form.watch("hcMode");
useEffect(() => { useEffect(() => {
if (!open) return; if (!open) return;
@@ -378,6 +381,8 @@ export function HealthCheckCredenza(props: HealthCheckCredenzaProps) {
form={form} form={form}
showNameField={mode === "submit"} showNameField={mode === "submit"}
hideEnabledField={mode === "submit"} hideEnabledField={mode === "submit"}
watchedEnabled={watchedEnabled}
watchedMode={watchedMode}
onFieldChange={ onFieldChange={
mode === "autoSave" mode === "autoSave"
? handleFieldChange ? handleFieldChange

View File

@@ -26,19 +26,21 @@ type HealthCheckFormFieldsProps = {
onFieldChange?: (fieldName: string, value: any) => void; onFieldChange?: (fieldName: string, value: any) => void;
showNameField?: boolean; showNameField?: boolean;
hideEnabledField?: boolean; hideEnabledField?: boolean;
watchedEnabled?: boolean;
watchedMode?: string;
}; };
export function HealthCheckFormFields({ export function HealthCheckFormFields({
form, form,
onFieldChange, onFieldChange,
showNameField, showNameField,
hideEnabledField hideEnabledField,
watchedEnabled,
watchedMode
}: HealthCheckFormFieldsProps) { }: HealthCheckFormFieldsProps) {
const t = useTranslations(); const t = useTranslations();
const watchedEnabled = form.watch("hcEnabled");
const showFields = hideEnabledField || watchedEnabled; const showFields = hideEnabledField || watchedEnabled;
const watchedMode = form.watch("hcMode");
const handleChange = (fieldName: string, value: any, fieldOnChange: (v: any) => void) => { const handleChange = (fieldName: string, value: any, fieldOnChange: (v: any) => void) => {
fieldOnChange(value); fieldOnChange(value);

View File

@@ -22,7 +22,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
import { ArrowUpDown, MoreHorizontal } from "lucide-react"; import { ArrowUpDown, MoreHorizontal } from "lucide-react";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import { useState } from "react"; import { useState } from "react";
import { Span } from "next/dist/trace";
type StandaloneHealthChecksTableProps = { type StandaloneHealthChecksTableProps = {
orgId: string; orgId: string;
@@ -57,12 +57,6 @@ const healthVariant: Record<
unknown: "secondary" unknown: "secondary"
}; };
function HealthBadge({ health }: { health: HealthCheckRow["hcHealth"] }) {
return (
<Badge variant={healthVariant[health]}>{healthLabel[health]}</Badge>
);
}
export default function HealthChecksTable({ export default function HealthChecksTable({
orgId orgId
}: StandaloneHealthChecksTableProps) { }: StandaloneHealthChecksTableProps) {
@@ -146,7 +140,7 @@ export default function HealthChecksTable({
</Button> </Button>
), ),
cell: ({ row }) => ( cell: ({ row }) => (
<span className="font-medium">{row.original.name}</span> <span>{row.original.name}</span>
) )
}, },
{ {
@@ -156,7 +150,7 @@ export default function HealthChecksTable({
<span className="p-3">{t("standaloneHcColumnMode")}</span> <span className="p-3">{t("standaloneHcColumnMode")}</span>
), ),
cell: ({ row }) => ( cell: ({ row }) => (
<span className="uppercase text-xs font-mono"> <span>
{row.original.hcMode?.toUpperCase() ?? "—"} {row.original.hcMode?.toUpperCase() ?? "—"}
</span> </span>
) )
@@ -167,11 +161,7 @@ export default function HealthChecksTable({
header: () => ( header: () => (
<span className="p-3">{t("standaloneHcColumnTarget")}</span> <span className="p-3">{t("standaloneHcColumnTarget")}</span>
), ),
cell: ({ row }) => ( cell: ({ row }) => <span>{formatTarget(row.original)}</span>
<span className="font-mono text-xs text-muted-foreground truncate max-w-64 block">
{formatTarget(row.original)}
</span>
)
}, },
{ {
id: "health", id: "health",
@@ -179,9 +169,31 @@ export default function HealthChecksTable({
header: () => ( header: () => (
<span className="p-3">{t("standaloneHcColumnHealth")}</span> <span className="p-3">{t("standaloneHcColumnHealth")}</span>
), ),
cell: ({ row }) => ( cell: ({ row }) => {
<HealthBadge health={row.original.hcHealth} /> const health = row.original.hcHealth;
) if (health === "healthy") {
return (
<span className="text-green-500 flex items-center space-x-2">
<div className="w-2 h-2 bg-green-500 rounded-full"></div>
<span>{healthLabel.healthy}</span>
</span>
);
} else if (health === "unhealthy") {
return (
<span className="text-red-500 flex items-center space-x-2">
<div className="w-2 h-2 bg-red-500 rounded-full"></div>
<span>{healthLabel.unhealthy}</span>
</span>
);
} else {
return (
<span className="text-neutral-500 flex items-center space-x-2">
<div className="w-2 h-2 bg-gray-500 rounded-full"></div>
<span>{healthLabel.unknown}</span>
</span>
);
}
}
}, },
{ {
accessorKey: "hcEnabled", accessorKey: "hcEnabled",