diff --git a/src/components/ScrollArea.tsx b/src/components/ScrollArea.tsx index 1f5551aa..4f8c6925 100644 --- a/src/components/ScrollArea.tsx +++ b/src/components/ScrollArea.tsx @@ -1,5 +1,3 @@ -"use client"; - import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"; import { cn } from "@utils/helpers"; import * as React from "react"; @@ -15,46 +13,31 @@ const ScrollArea = React.forwardRef< >(({ className, children, withoutViewport = false, ...props }, ref) => ( {withoutViewport ? ( children ) : ( - - {children} - + {children} )} - + + )); ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName; -type AdditionalScrollAreaViewportProps = { - disableOverflowY?: boolean; -}; - const ScrollAreaViewport = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef & - AdditionalScrollAreaViewportProps ->(({ disableOverflowY = true, ...props }, ref) => { - return ( - - ); -}); + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); ScrollAreaViewport.displayName = ScrollAreaPrimitive.Viewport.displayName; const ScrollBar = React.forwardRef< @@ -63,14 +46,11 @@ const ScrollBar = React.forwardRef< >(({ className, orientation = "vertical", ...props }, ref) => ( diff --git a/src/modules/setup-keys/SetupKeyModal.tsx b/src/modules/setup-keys/SetupKeyModal.tsx index 3192cff1..57d45a80 100644 --- a/src/modules/setup-keys/SetupKeyModal.tsx +++ b/src/modules/setup-keys/SetupKeyModal.tsx @@ -23,7 +23,7 @@ import { cn } from "@utils/helpers"; import { trim } from "lodash"; import { AlarmClock, - CopyIcon, + DownloadIcon, ExternalLinkIcon, MonitorSmartphoneIcon, PlusCircle, @@ -35,20 +35,24 @@ import SetupKeysIcon from "@/assets/icons/SetupKeysIcon"; import useCopyToClipboard from "@/hooks/useCopyToClipboard"; import { SetupKey } from "@/interfaces/SetupKey"; import useGroupHelper from "@/modules/groups/useGroupHelper"; +import SetupModal from "@/modules/setup-netbird-modal/SetupModal"; type Props = { children?: React.ReactNode; open: boolean; setOpen: (open: boolean) => void; + name?: string; }; const copyMessage = "Setup-Key was copied to your clipboard!"; export default function SetupKeyModal({ children, open, setOpen, + name, }: Readonly) { const [successModal, setSuccessModal] = useState(false); const [setupKey, setSetupKey] = useState(); + const [installModal, setInstallModal] = useState(false); const [, copy] = useCopyToClipboard(setupKey?.key); const handleSuccess = (setupKey: SetupKey) => { @@ -60,8 +64,20 @@ export default function SetupKeyModal({ <> {children && {children}} - + + + { + setInstallModal(state); + setOpen(false); + }} + key={installModal ? 2 : 3} + > + + + { @@ -118,10 +134,10 @@ export default function SetupKeyModal({ variant={"primary"} className={"w-full"} data-cy={"setup-key-copy"} - onClick={() => copy(copyMessage)} + onClick={() => setInstallModal(true)} > - - Copy to clipboard + + Install NetBird @@ -133,13 +149,17 @@ export default function SetupKeyModal({ type ModalProps = { onSuccess?: (setupKey: SetupKey) => void; + predefinedName?: string; }; -export function SetupKeyModalContent({ onSuccess }: Readonly) { +export function SetupKeyModalContent({ + onSuccess, + predefinedName = "", +}: Readonly) { const setupKeyRequest = useApiCall("/setup-keys", true); const { mutate } = useSWRConfig(); - const [name, setName] = useState(""); + const [name, setName] = useState(predefinedName); const [reusable, setReusable] = useState(false); const [usageLimit, setUsageLimit] = useState(""); const [expiresIn, setExpiresIn] = useState("7"); diff --git a/src/modules/setup-netbird-modal/DockerTab.tsx b/src/modules/setup-netbird-modal/DockerTab.tsx index eb35b000..546f1020 100644 --- a/src/modules/setup-netbird-modal/DockerTab.tsx +++ b/src/modules/setup-netbird-modal/DockerTab.tsx @@ -10,7 +10,11 @@ import Link from "next/link"; import React from "react"; import { OperatingSystem } from "@/interfaces/OperatingSystem"; -export default function DockerTab() { +type Props = { + setupKey?: string; +}; + +export default function DockerTab({ setupKey }: Readonly) { return ( @@ -42,7 +46,10 @@ export default function DockerTab() { {" "} -e NB_SETUP_KEY= - SETUP_KEY \ + + {setupKey ?? "SETUP_KEY"} + {" "} + \ -v netbird-client:/etc/netbird \ {GRPC_API_ORIGIN && ( diff --git a/src/modules/setup-netbird-modal/LinuxTab.tsx b/src/modules/setup-netbird-modal/LinuxTab.tsx index 9fcadaae..51fc5034 100644 --- a/src/modules/setup-netbird-modal/LinuxTab.tsx +++ b/src/modules/setup-netbird-modal/LinuxTab.tsx @@ -13,8 +13,13 @@ import { getNetBirdUpCommand } from "@utils/netbird"; import { TerminalSquareIcon } from "lucide-react"; import React from "react"; import { OperatingSystem } from "@/interfaces/OperatingSystem"; +import { SetupKeyParameter } from "@/modules/setup-netbird-modal/SetupModal"; -export default function LinuxTab() { +type Props = { + setupKey?: string; +}; + +export default function LinuxTab({ setupKey }: Readonly) { return ( @@ -27,9 +32,12 @@ export default function LinuxTab() { curl -fsSL https://pkgs.netbird.io/install.sh | sh -

Run NetBird and log in the browser

+

Run NetBird {!setupKey && "and log in the browser"}

- {getNetBirdUpCommand()} + + {getNetBirdUpCommand()} + +
@@ -78,9 +86,12 @@ export default function LinuxTab() { -

Run NetBird and log in the browser

+

Run NetBird {!setupKey && "and log in the browser"}

- {getNetBirdUpCommand()} + + {getNetBirdUpCommand()} + +
diff --git a/src/modules/setup-netbird-modal/MacOSTab.tsx b/src/modules/setup-netbird-modal/MacOSTab.tsx index a9b5964c..7e4f1525 100644 --- a/src/modules/setup-netbird-modal/MacOSTab.tsx +++ b/src/modules/setup-netbird-modal/MacOSTab.tsx @@ -23,8 +23,12 @@ import { import Link from "next/link"; import React from "react"; import { OperatingSystem } from "@/interfaces/OperatingSystem"; +import { SetupKeyParameter } from "@/modules/setup-netbird-modal/SetupModal"; -export default function MacOSTab() { +type Props = { + setupKey?: string; +}; +export default function MacOSTab({ setupKey }: Readonly) { return ( @@ -98,15 +102,29 @@ export default function MacOSTab() { )} - -

- {/* eslint-disable-next-line react/no-unescaped-entities */} - Click on "Connect" from the NetBird icon in your system tray -

-
- -

Sign up using your email address

-
+ {setupKey ? ( + +

Open Terminal and run NetBird

+ + + {getNetBirdUpCommand()} + + + +
+ ) : ( + <> + +

+ {/* eslint-disable-next-line react/no-unescaped-entities */} + Click on "Connect" from the NetBird icon in your system tray +

+
+ +

Sign up using your email address

+
+ + )}
@@ -125,9 +143,12 @@ export default function MacOSTab() { -

Run NetBird and log in the browser

+

Run NetBird {!setupKey && "and log in the browser"}

- {getNetBirdUpCommand()} + + {getNetBirdUpCommand()} + +
@@ -179,9 +200,12 @@ export default function MacOSTab() { -

Run NetBird and log in the browser

+

Run NetBird {!setupKey && "and log in the browser"}

- {getNetBirdUpCommand()} + + {getNetBirdUpCommand()} + +
diff --git a/src/modules/setup-netbird-modal/SetupModal.tsx b/src/modules/setup-netbird-modal/SetupModal.tsx index e7a4d591..7f88a94b 100644 --- a/src/modules/setup-netbird-modal/SetupModal.tsx +++ b/src/modules/setup-netbird-modal/SetupModal.tsx @@ -5,6 +5,7 @@ import { ModalContent, ModalFooter } from "@components/modal/Modal"; import Paragraph from "@components/Paragraph"; import SmallParagraph from "@components/SmallParagraph"; import { Tabs, TabsList, TabsTrigger } from "@components/Tabs"; +import { cn } from "@utils/helpers"; import { ExternalLinkIcon } from "lucide-react"; import { usePathname } from "next/navigation"; import React from "react"; @@ -31,27 +32,36 @@ type OidcUserInfo = { type Props = { showClose?: boolean; user?: OidcUserInfo; + setupKey?: string; }; -export default function SetupModal({ showClose = true, user }: Props) { +export default function SetupModal({ + showClose = true, + user, + setupKey, +}: Readonly) { return ( - + ); } +type SetupModalContentProps = { + user?: OidcUserInfo; + header?: boolean; + footer?: boolean; + tabAlignment?: "center" | "start" | "end"; + setupKey?: string; +}; + export function SetupModalContent({ user, header = true, footer = true, tabAlignment = "center", -}: { - user?: OidcUserInfo; - header?: boolean; - footer?: boolean; - tabAlignment?: "center" | "start" | "end"; -}) { + setupKey, +}: Readonly) { const os = useOperatingSystem(); const [isFirstRun] = useLocalStorage("netbird-first-run", true); const pathname = usePathname(); @@ -60,24 +70,33 @@ export function SetupModalContent({ return ( <> {header && ( -
-

+
+

{isFirstRun && !isInstallPage ? ( <> Hello {user?.given_name || "there"}! 👋
{`It's time to add your first device.`} ) : ( - <>Install NetBird + <>Install NetBird{setupKey && " with Setup Key"} )}

- - To get started, install NetBird and log in with your email account. + + {setupKey + ? "To get started, install and run NetBird with your recently created setup key as a parameter." + : "To get started, install NetBird and log in with your email account."}
)} - + macOS - - - iOS - - - - Android - + + {!setupKey && ( + <> + + + iOS + + + + Android + + + )} + - - - - - - + + + + + + {!setupKey && ( + <> + + + + )} + + {footer && ( @@ -158,3 +190,18 @@ export function SetupModalContent({ ); } + +type SetupKeyParameterProps = { + setupKey?: string; +}; + +export const SetupKeyParameter = ({ setupKey }: SetupKeyParameterProps) => { + return ( + setupKey && ( + <> + {" "} + --setup-key {setupKey}{" "} + + ) + ); +}; diff --git a/src/modules/setup-netbird-modal/WindowsTab.tsx b/src/modules/setup-netbird-modal/WindowsTab.tsx index 49bc7d0a..1a6a01ba 100644 --- a/src/modules/setup-netbird-modal/WindowsTab.tsx +++ b/src/modules/setup-netbird-modal/WindowsTab.tsx @@ -2,13 +2,18 @@ import Button from "@components/Button"; import Code from "@components/Code"; import Steps from "@components/Steps"; import TabsContentPadding, { TabsContent } from "@components/Tabs"; -import { GRPC_API_ORIGIN } from "@utils/netbird"; +import { getNetBirdUpCommand, GRPC_API_ORIGIN } from "@utils/netbird"; import { DownloadIcon, PackageOpenIcon } from "lucide-react"; import Link from "next/link"; import React from "react"; import { OperatingSystem } from "@/interfaces/OperatingSystem"; +import { SetupKeyParameter } from "@/modules/setup-netbird-modal/SetupModal"; -export default function WindowsTab() { +type Props = { + setupKey?: string; +}; + +export default function WindowsTab({ setupKey }: Readonly) { return ( @@ -44,15 +49,29 @@ export default function WindowsTab() { )} - -

- {/* eslint-disable-next-line react/no-unescaped-entities */} - Click on "Connect" from the NetBird icon in your system tray -

-
- -

Sign up using your email address

-
+ {setupKey ? ( + +

Open Command-line and run NetBird

+ + + {getNetBirdUpCommand()} + + + +
+ ) : ( + <> + +

+ {/* eslint-disable-next-line react/no-unescaped-entities */} + Click on "Connect" from the NetBird icon in your system tray +

+
+ +

Sign up using your email address

+
+ + )}