Skip to content

Commit c2043a4

Browse files
authored
Merge pull request #43 from Ratio1/tunnel-delete-confirm
feat: message on active tunnels delete
2 parents 894fab7 + e680f66 commit c2043a4

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

app/(protected)/tunnels/[id]/page.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,28 @@ export default function TunnelPage() {
9898
throw new Error('Tunneling secrets not found.');
9999
}
100100

101-
await confirm(<div>Are you sure you want to delete this tunnel?</div>, {
102-
onConfirm: async () => {
103-
try {
104-
await deleteTunnel(tunnel.id, tunnelingSecrets);
105-
toast.success('Tunnel deleted successfully.');
106-
router.push(routePath.tunnels);
107-
} catch (error: any) {
108-
console.error('Error deleting tunnel:', error);
109-
toast.error(error.message);
110-
}
101+
await confirm(
102+
<div className="col gap-3">
103+
Are you sure you want to delete this tunnel?
104+
{tunnel.status === 'healthy' && (
105+
<div className="text-sm text-red-500">
106+
Warning: Deleting an active tunnel will immediately stop all traffic routed through it.
107+
</div>
108+
)}
109+
</div>,
110+
{
111+
onConfirm: async () => {
112+
try {
113+
await deleteTunnel(tunnel.id, tunnelingSecrets);
114+
toast.success('Tunnel deleted successfully.');
115+
router.push(routePath.tunnels);
116+
} catch (error: any) {
117+
console.error('Error deleting tunnel:', error);
118+
toast.error(error.message);
119+
}
120+
},
111121
},
112-
});
122+
);
113123
} catch (error) {
114124
console.error('Error deleting tunnel:', error);
115125
toast.error('Failed to delete tunnel.');

src/components/tunnels/TunnelCard.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export default function TunnelCard({ tunnel, fetchTunnels }: { tunnel: Tunnel; f
3131
<div className="col gap-3">
3232
<div>Are you sure you want to delete the following tunnel?</div>
3333
<div className="font-medium">{tunnel.alias}</div>
34+
{tunnel.status === 'healthy' && (
35+
<div className="text-sm text-red-500">
36+
Warning: Deleting an active tunnel will immediately stop all traffic routed through it.
37+
</div>
38+
)}
3439
</div>,
3540
{
3641
onConfirm: async () => {

0 commit comments

Comments
 (0)