Skip to content

Commit 44f28c8

Browse files
committed
Add confirm dialog to let the user know a one-off setup-key will be created. This avoids accidental clicking and later confusion on the setup keys page
1 parent 48bf8e0 commit 44f28c8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/modules/networks/routing-peers/NetworkRoutingPeerModal.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
} from "lucide-react";
3838
import React, { useState } from "react";
3939
import { useSWRConfig } from "swr";
40+
import { useDialog } from "@/contexts/DialogProvider";
4041
import { Network, NetworkRouter } from "@/interfaces/Network";
4142
import { Peer } from "@/interfaces/Peer";
4243
import { SetupKey } from "@/interfaces/SetupKey";
@@ -408,12 +409,23 @@ const InstallNetBirdWithSetupKeyButton = ({
408409
}: InstallNetBirdWithSetupKeyButtonProps) => {
409410
const setupKeyRequest = useApiCall<SetupKey>("/setup-keys", true);
410411
const { mutate } = useSWRConfig();
412+
const { confirm } = useDialog();
411413

412414
const [installModal, setInstallModal] = useState(false);
413415
const [setupKey, setSetupKey] = useState<SetupKey>();
414416
const [isLoading, setIsLoading] = useState(false);
415417

416418
const createSetupKey = async () => {
419+
const choice = await confirm({
420+
title: `Create a Setup Key?`,
421+
description:
422+
"If you continue, a one-off setup key will be automatically created and you will be able to install NetBird on a Linux machine.",
423+
confirmText: "Continue",
424+
cancelText: "Cancel",
425+
type: "default",
426+
});
427+
if (!choice) return;
428+
417429
const loadingTimeout = setTimeout(() => setIsLoading(true), 1000);
418430

419431
await setupKeyRequest

0 commit comments

Comments
 (0)