diff --git a/src/popup/components/FocusView.tsx b/src/popup/components/FocusView.tsx
index 87dda23..b54f279 100644
--- a/src/popup/components/FocusView.tsx
+++ b/src/popup/components/FocusView.tsx
@@ -6,7 +6,7 @@ import { storage } from 'webextension-polyfill';
import { getGitKrakenDeepLinkUrl } from '../../deepLink';
import { ProviderMeta } from '../../providers';
import { GKDotDevUrl } from '../../shared';
-import type { FocusViewSupportedProvider } from '../../types';
+import type { FocusViewDataError, FocusViewSupportedProvider } from '../../types';
import { useFocusViewConnectedProviders, useFocusViewDataQuery, usePullRequestDraftCountsQuery } from '../hooks';
import { ConnectAProvider } from './ConnectAProvider';
import { ExternalLink } from './ExternalLink';
@@ -189,6 +189,52 @@ export const FocusView = ({ userId }: { userId: string }) => {
return ;
}
+ let content: JSX.Element | null = null;
+ if (focusViewDataQuery.isLoading) {
+ content = (
+
+
+
+ );
+ } else if (focusViewDataQuery.error) {
+ const error = focusViewDataQuery.error as FocusViewDataError;
+ content = (
+
+
+ An unexpected error occurred trying to load Launchpad data.{' '}
+ {error.domain ? (
+ <>
+ Make sure the service at{' '}
+
+ {error.domain}
+ {' '}
+ is reachable. If it is, make sure your access token is still valid.
+ >
+ ) : (
+ 'Make sure your access token is still valid.'
+ )}
+
+
+ Manage Integration Settings
+
+
+ );
+ } else {
+ content = (
+
+ {filteredBuckets?.map(bucket => (
+
+ ))}
+
+ );
+ }
+
return (
{selectedProvider && (
@@ -224,23 +270,7 @@ export const FocusView = ({ userId }: { userId: string }) => {
)}
- {focusViewDataQuery.isLoading ? (
-
-
-
- ) : (
-
- {filteredBuckets?.map(bucket => (
-
- ))}
-
- )}
+ {content}
);
};
diff --git a/src/providers.ts b/src/providers.ts
index 905a8c8..cfd0e12 100644
--- a/src/providers.ts
+++ b/src/providers.ts
@@ -133,20 +133,27 @@ export const fetchFocusViewData = async (provider: FocusViewSupportedProvider):
return null;
}
- switch (provider) {
- case 'github':
- case 'githubEnterprise':
- return fetchGitHubFocusViewData(providerToken);
- case 'gitlab':
- case 'gitlabSelfHosted':
- return fetchGitLabFocusViewData(providerToken);
- case 'bitbucket':
- return fetchBitbucketFocusViewData(providerToken);
- case 'bitbucketServer':
- return fetchBitbucketServerFocusViewData(providerToken);
- case 'azure':
- return fetchAzureFocusViewData(providerToken);
- default:
- throw new Error(`Attempted to fetch pull requests for unsupported provider: ${provider as Provider}`);
+ try {
+ switch (provider) {
+ case 'github':
+ case 'githubEnterprise':
+ return await fetchGitHubFocusViewData(providerToken);
+ case 'gitlab':
+ case 'gitlabSelfHosted':
+ return await fetchGitLabFocusViewData(providerToken);
+ case 'bitbucket':
+ return await fetchBitbucketFocusViewData(providerToken);
+ case 'bitbucketServer':
+ return await fetchBitbucketServerFocusViewData(providerToken);
+ case 'azure':
+ return await fetchAzureFocusViewData(providerToken);
+ default:
+ throw new Error(`Attempted to fetch pull requests for unsupported provider: ${provider as Provider}`);
+ }
+ } catch (e) {
+ if (e) {
+ Object.assign(e, { provider: provider, domain: providerToken.domain });
+ }
+ throw e;
}
};
diff --git a/src/types.ts b/src/types.ts
index 300b8d7..0eb533c 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -40,6 +40,11 @@ export type FocusViewData = {
pullRequests: PullRequestWithUniqueID[];
};
+export type FocusViewDataError = Error & {
+ provider?: Provider;
+ domain?: string;
+};
+
export interface ProviderConnection {
provider: Provider;
type: string;
diff --git a/static/popup.css b/static/popup.css
index 96c2da4..b3a21ae 100644
--- a/static/popup.css
+++ b/static/popup.css
@@ -269,6 +269,16 @@ html {
margin-right: 4px;
}
+/* Focus View - Error */
+.focus-view .focus-view-error {
+ display: flex;
+ flex-direction: column;
+}
+.focus-view .focus-view-error .manage-integrations {
+ text-align: center;
+ margin-top: 8px;
+}
+
/* Generic components */
button.icon-btn {
background: none;