diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-05-20 11:17:58 +0200 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-05-28 13:25:40 +0200 |
| commit | a42776ff70d77417d0fab712c36cfbcb79766343 (patch) | |
| tree | 59256dbe595c2fcdbfa9a9080b136d80d3138c7e /desktop | |
| parent | e43feef72c986228aab3082f889f2378f51c5352 (diff) | |
| download | mullvadvpn-a42776ff70d77417d0fab712c36cfbcb79766343.tar.xz mullvadvpn-a42776ff70d77417d0fab712c36cfbcb79766343.zip | |
Add support to external links to open with auth
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/packages/mullvad-vpn/src/renderer/components/ExternalLink.tsx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/ExternalLink.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/ExternalLink.tsx index 4f160ad64d..16238b7c3c 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/ExternalLink.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/ExternalLink.tsx @@ -6,19 +6,24 @@ import { Link, LinkProps } from '../lib/components'; export type ExternalLinkProps = Omit<LinkProps, 'href' | 'as'> & { to: Url; + withAuth?: boolean; }; -function ExternalLink({ to, onClick, ...props }: ExternalLinkProps) { - const { openUrl } = useAppContext(); +function ExternalLink({ to, onClick, withAuth, ...props }: ExternalLinkProps) { + const { openUrl, openUrlWithAuth } = useAppContext(); const navigate = useCallback( (e: React.MouseEvent<HTMLAnchorElement>) => { e.preventDefault(); if (onClick) { onClick(e); } + + if (withAuth) { + return openUrlWithAuth(to); + } return openUrl(to); }, - [onClick, openUrl, to], + [onClick, openUrl, openUrlWithAuth, to, withAuth], ); return <Link href="" onClick={navigate} {...props} />; } |
