mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Display git provider favicon in SyncStep
This commit is contained in:
4 files changed
+22
-31
No files matched your search
@@ -1,12 +1,11 @@
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { faviconUrl } from '@/lib/faviconUrl';
|
||||
import { normalizeUrl } from '@/lib/url';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { ReactNode, useMemo } from 'react';
|
||||
|
||||
interface ExternalFaviconProps {
|
||||
/** The URL to fetch the favicon for */
|
||||
url: string;
|
||||
url: string | URL;
|
||||
/** Size of the favicon in pixels */
|
||||
size?: number;
|
||||
/** Fallback element to display if favicon fails to load */
|
||||
@@ -31,8 +30,7 @@ export function ExternalFavicon({
|
||||
const faviconSrc = useMemo(() => {
|
||||
try {
|
||||
// Normalize the URL to ensure it has a protocol
|
||||
const normalizedUrl = normalizeUrl(url);
|
||||
return faviconUrl(config.faviconUrl, normalizedUrl);
|
||||
return faviconUrl(config.faviconUrl, url);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,19 +208,11 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) {
|
||||
|
||||
// Check if we have a matched credential
|
||||
const matchedCredential = findCredentialsForRepo(remoteUrl, settings.credentials);
|
||||
if (matchedCredential) {
|
||||
return {
|
||||
name: matchedCredential.name,
|
||||
icon: (
|
||||
<ExternalFavicon
|
||||
url={matchedCredential.origin}
|
||||
size={16}
|
||||
/>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return { name: remoteUrl.hostname };
|
||||
return {
|
||||
name: matchedCredential? matchedCredential.name : remoteUrl.hostname,
|
||||
icon: <ExternalFavicon url={remoteUrl} size={16} />,
|
||||
};
|
||||
}, [remoteUrl, settings.credentials]);
|
||||
|
||||
const providerInfo = getProviderInfo();
|
||||
|
||||
Reference in new issue
Block a user