*Only cloud-hosted providers are currently supported.
diff --git a/src/popup/components/ExternalLink.tsx b/src/popup/components/ExternalLink.tsx
new file mode 100644
index 0000000..97f751d
--- /dev/null
+++ b/src/popup/components/ExternalLink.tsx
@@ -0,0 +1,42 @@
+import React from 'react';
+import { tabs } from 'webextension-polyfill';
+
+type ExternalLinkProps = {
+ children: React.ReactNode;
+ className?: string;
+ href?: string;
+ onClick?: () => any;
+ title?: string;
+};
+
+export const ExternalLink = ({ children, className, href, onClick, title }: ExternalLinkProps) => {
+ return (
+
{
+ // Opening external links in Firefox will not cause the popup to automatically close,
+ // so we must manually close it.
+
+ // Closing the popup window before the link has finished opening will cause Firefox to open
+ // the link in a new window instead of in a new tab. In order to prevent this, we manually
+ // open the link in a new tab and await that, then close the popup window afterwards.
+ e.preventDefault();
+
+ if (onClick) {
+ await onClick();
+ }
+ if (href) {
+ await tabs.create({ url: href });
+ }
+
+ window.close();
+ }}
+ >
+ {children}
+
+ );
+};
diff --git a/src/popup/components/FocusView.tsx b/src/popup/components/FocusView.tsx
index 6448f12..8478978 100644
--- a/src/popup/components/FocusView.tsx
+++ b/src/popup/components/FocusView.tsx
@@ -2,7 +2,7 @@ import { GitProviderUtils } from '@gitkraken/provider-apis';
import { useQueryClient } from '@tanstack/react-query';
import React, { useEffect, useMemo, useState } from 'react';
import { storage } from 'webextension-polyfill';
-import { openGitKrakenDeepLink } from '../../deepLink';
+import { getGitKrakenDeepLinkUrl } from '../../deepLink';
import { ProviderMeta } from '../../providers';
import { GKDotDevUrl } from '../../shared';
import type {
@@ -12,6 +12,7 @@ import type {
} from '../../types';
import { useFocusViewConnectedProviders, useFocusViewDataQuery, usePullRequestDraftCountsQuery } from '../hooks';
import { ConnectAProvider } from './ConnectAProvider';
+import { ExternalLink } from './ExternalLink';
type PullRequestRowProps = {
userId: string;
@@ -22,6 +23,7 @@ type PullRequestRowProps = {
const PullRequestRow = ({ userId, pullRequest, provider, draftCount = 0 }: PullRequestRowProps) => {
const queryClient = useQueryClient();
+ const deepLinkUrl = getGitKrakenDeepLinkUrl(provider, pullRequest.url);
return (
<>
@@ -29,10 +31,9 @@ const PullRequestRow = ({ userId, pullRequest, provider, draftCount = 0 }: PullR
{pullRequest.title}
{pullRequest.repository.name}
- {pullRequest.url && (
-
{
- openGitKrakenDeepLink(provider, pullRequest.url);
- }}
- title="Open with GitKraken"
- >
+ {deepLinkUrl && (
+
-
+
)}
+
)}
>
);
diff --git a/src/popup/components/SignedIn.tsx b/src/popup/components/SignedIn.tsx
index 2140ff2..cc6fae9 100644
--- a/src/popup/components/SignedIn.tsx
+++ b/src/popup/components/SignedIn.tsx
@@ -3,6 +3,7 @@ import { logoutUser } from '../../gkApi';
import type { PermissionsRequest } from '../../permissions-helper';
import { GKDotDevUrl } from '../../shared';
import type { User } from '../../types';
+import { ExternalLink } from './ExternalLink';
import { FocusView } from './FocusView';
import { RequestPermissionsBanner } from './RequestPermissionsBanner';
@@ -45,9 +46,9 @@ export const SignedIn = ({ permissionsRequest, user }: { permissionsRequest?: Pe