diff options
| -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} />; } |
