use standard error alert

This commit is contained in:
miloschwartz
2026-06-04 17:44:45 -07:00
parent 6b04bcb383
commit ff507f1275
3 changed files with 53 additions and 46 deletions

View File

@@ -22,6 +22,7 @@ import {
CardTitle,
CardDescription
} from "@app/components/ui/card";
import { Alert, AlertDescription } from "@app/components/ui/alert";
import BrandedAuthSurface from "@app/components/BrandedAuthSurface";
import PoweredByPangolin from "@app/components/PoweredByPangolin";
import { useTranslations } from "next-intl";
@@ -92,6 +93,7 @@ export default function RdpClient({
const [showLogin, setShowLogin] = useState(true);
const [moduleReady, setModuleReady] = useState(false);
const [connecting, setConnecting] = useState(false);
const [submitError, setSubmitError] = useState<string | null>(null);
const [unicodeMode, setUnicodeMode] = useState(false);
const [cursorOverrideActive, setCursorOverrideActive] = useState(false);
@@ -170,16 +172,13 @@ export default function RdpClient({
};
const startSession = async () => {
setSubmitError(null);
setConnecting(true);
const userInteraction = userInteractionRef.current;
const exts = extensionsRef.current;
if (!userInteraction || !exts) {
setConnecting(false);
toast({
variant: "destructive",
title: t("rdpNotReady"),
description: t("rdpModuleInitializing")
});
setSubmitError(t("rdpModuleInitializing"));
return;
}
@@ -241,11 +240,7 @@ export default function RdpClient({
if (!target) {
setConnecting(false);
toast({
variant: "destructive",
title: t("browserGatewayNoTarget"),
description: t("rdpNoConnectionTarget")
});
setSubmitError(t("rdpNoConnectionTarget"));
return;
}
@@ -294,17 +289,9 @@ export default function RdpClient({
setConnecting(false);
setShowLogin(true);
if (isIronError(err)) {
toast({
variant: "destructive",
title: t("rdpConnectionFailed"),
description: err.backtrace()
});
setSubmitError(err.backtrace());
} else {
toast({
variant: "destructive",
title: t("rdpConnectionFailed"),
description: `${err}`
});
setSubmitError(`${err}`);
}
}
};
@@ -331,7 +318,9 @@ export default function RdpClient({
<CardTitle>{t("rdpTitle")}</CardTitle>
</CardHeader>
<CardContent>
<p className="text-destructive text-sm">{error}</p>
<Alert variant="destructive">
<AlertDescription>{error}</AlertDescription>
</Alert>
</CardContent>
</Card>
</BrandedAuthSurface>
@@ -413,6 +402,14 @@ export default function RdpClient({
Enable Clipboard
</Label>
</div> */}
{submitError && (
<Alert variant="destructive">
<AlertDescription>
{submitError}
</AlertDescription>
</Alert>
)}
<Button
onClick={startSession}
disabled={!moduleReady}

View File

@@ -15,7 +15,7 @@ import {
CardDescription
} from "@app/components/ui/card";
import Link from "next/link";
import { ExternalLink, Loader2, AlertCircle } from "lucide-react";
import { ExternalLink, Loader2 } from "lucide-react";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { HorizontalTabs } from "@app/components/HorizontalTabs";
import type { SignSshKeyResponse } from "@server/routers/ssh/types";
@@ -352,11 +352,7 @@ export default function SshClient({
</div>
)}
{connectError && (
<Alert
variant="destructive"
className="w-full"
>
<AlertCircle className="h-5 w-5" />
<Alert variant="destructive" className="w-full">
<AlertDescription>
{connectError}
</AlertDescription>
@@ -388,7 +384,9 @@ export default function SshClient({
<CardTitle>{t("sshTitle")}</CardTitle>
</CardHeader>
<CardContent>
<p className="text-destructive text-sm">{error}</p>
<Alert variant="destructive">
<AlertDescription>{error}</AlertDescription>
</Alert>
</CardContent>
</Card>
</BrandedAuthSurface>
@@ -447,9 +445,11 @@ export default function SshClient({
</Field>
<div className="mt-4 space-y-3">
{connectError && (
<p className="text-destructive text-sm">
{connectError}
</p>
<Alert variant="destructive">
<AlertDescription>
{connectError}
</AlertDescription>
</Alert>
)}
<Button
@@ -530,9 +530,11 @@ export default function SshClient({
</Field>
<div className="mt-4 space-y-3">
{connectError && (
<p className="text-destructive text-sm">
{connectError}
</p>
<Alert variant="destructive">
<AlertDescription>
{connectError}
</AlertDescription>
</Alert>
)}
<Button

View File

@@ -13,6 +13,7 @@ import {
CardTitle,
CardDescription
} from "@app/components/ui/card";
import { Alert, AlertDescription } from "@app/components/ui/alert";
import BrandedAuthSurface from "@app/components/BrandedAuthSurface";
import PoweredByPangolin from "@app/components/PoweredByPangolin";
import { useTranslations } from "next-intl";
@@ -44,6 +45,7 @@ export default function VncClient({
});
const [connected, setConnected] = useState(false);
const [connectError, setConnectError] = useState<string | null>(null);
const rfbRef = useRef<any>(null);
const screenRef = useRef<HTMLDivElement>(null);
@@ -66,12 +68,10 @@ export default function VncClient({
}, []);
const connect = async () => {
setConnectError(null);
if (!target) {
toast({
variant: "destructive",
title: t("browserGatewayNoTarget"),
description: t("vncNoResourceTarget")
});
setConnectError(t("vncNoResourceTarget"));
return;
}
@@ -144,15 +144,13 @@ export default function VncClient({
rfb.addEventListener(
"securityfailure",
(e: { detail: { status: number; reason?: string } }) => {
toast({
variant: "destructive",
title: t("sshErrorAuthFailed"),
description:
e.detail.reason ??
disconnect();
setConnectError(
e.detail.reason ??
t("vncAuthFailedStatus", {
status: e.detail.status
})
});
);
}
);
@@ -168,7 +166,9 @@ export default function VncClient({
<CardTitle>{t("vncTitle")}</CardTitle>
</CardHeader>
<CardContent>
<p className="text-destructive text-sm">{error}</p>
<Alert variant="destructive">
<AlertDescription>{error}</AlertDescription>
</Alert>
</CardContent>
</Card>
</BrandedAuthSurface>
@@ -203,6 +203,14 @@ export default function VncClient({
/>
</Field>
{connectError && (
<Alert variant="destructive">
<AlertDescription>
{connectError}
</AlertDescription>
</Alert>
)}
<Button onClick={connect} className="w-full">
{t("browserGatewayConnect")}
</Button>