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