mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-17 14:34:42 +00:00
Clean up toasts
This commit is contained in:
@@ -4,7 +4,6 @@ import { useEffect, useRef, useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { toast } from "@app/hooks/useToast";
|
||||
import type {
|
||||
UserInteraction,
|
||||
@@ -74,6 +73,7 @@ export default function RdpClient({
|
||||
|
||||
const [showLogin, setShowLogin] = useState(true);
|
||||
const [moduleReady, setModuleReady] = useState(false);
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
const [unicodeMode, setUnicodeMode] = useState(false);
|
||||
const [cursorOverrideActive, setCursorOverrideActive] = useState(false);
|
||||
|
||||
@@ -152,9 +152,11 @@ export default function RdpClient({
|
||||
};
|
||||
|
||||
const startSession = async () => {
|
||||
setConnecting(true);
|
||||
const userInteraction = userInteractionRef.current;
|
||||
const exts = extensionsRef.current;
|
||||
if (!userInteraction || !exts) {
|
||||
setConnecting(false);
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Not ready",
|
||||
@@ -163,11 +165,6 @@ export default function RdpClient({
|
||||
return;
|
||||
}
|
||||
|
||||
toast({
|
||||
title: "Connecting...",
|
||||
description: "Connection in progress"
|
||||
});
|
||||
|
||||
userInteraction.setEnableClipboard(form.enableClipboard);
|
||||
|
||||
// Dispose any previous session's provider and create a fresh one so
|
||||
@@ -221,6 +218,7 @@ export default function RdpClient({
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
setConnecting(false);
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "No target",
|
||||
@@ -257,19 +255,16 @@ export default function RdpClient({
|
||||
try {
|
||||
const sessionInfo = await userInteraction.connect(builder.build());
|
||||
|
||||
toast({ title: "Connected" });
|
||||
setConnecting(false);
|
||||
setShowLogin(false);
|
||||
userInteraction.setVisibility(true);
|
||||
|
||||
const termInfo = await sessionInfo.run();
|
||||
fileTransferRef.current?.dispose();
|
||||
fileTransferRef.current = null;
|
||||
toast({
|
||||
title: "Session terminated",
|
||||
description: termInfo.reason()
|
||||
});
|
||||
setShowLogin(true);
|
||||
} catch (err) {
|
||||
setConnecting(false);
|
||||
setShowLogin(true);
|
||||
if (isIronError(err)) {
|
||||
toast({
|
||||
@@ -381,6 +376,7 @@ export default function RdpClient({
|
||||
<Button
|
||||
onClick={startSession}
|
||||
disabled={!moduleReady}
|
||||
loading={connecting}
|
||||
className="w-full"
|
||||
>
|
||||
{moduleReady ? "Connect" : "Loading module..."}
|
||||
|
||||
@@ -250,7 +250,7 @@ export default function SshClient({
|
||||
disabled={connecting || !form.username}
|
||||
className="w-full"
|
||||
>
|
||||
{connecting ? "Connecting…" : "Connect"}
|
||||
{connecting ? "Connecting..." : "Connect"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,8 +96,6 @@ export default function VncClient({
|
||||
});
|
||||
const wsUrl = `${base}?${params.toString()}`;
|
||||
|
||||
toast({ title: "Connecting…", description: wsUrl });
|
||||
|
||||
// Clear the container so noVNC gets a clean mount point.
|
||||
screenRef.current.innerHTML = "";
|
||||
|
||||
@@ -113,7 +111,6 @@ export default function VncClient({
|
||||
rfb.resizeSession = true;
|
||||
|
||||
rfb.addEventListener("connect", () => {
|
||||
toast({ title: "Connected" });
|
||||
setConnected(true);
|
||||
});
|
||||
|
||||
@@ -122,10 +119,6 @@ export default function VncClient({
|
||||
(e: { detail: { clean: boolean } }) => {
|
||||
rfbRef.current = null;
|
||||
setConnected(false);
|
||||
toast({
|
||||
title: e.detail.clean ? "Disconnected" : "Connection lost",
|
||||
variant: e.detail.clean ? "default" : "destructive"
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user