Remove GitHub status badge

This commit is contained in:
Sam Becker 2025-02-14 21:06:34 -06:00
parent 3525edab37
commit a59164aadb
8 changed files with 14 additions and 165 deletions

View File

@ -1,4 +1,7 @@
import { getGitHubMetaWithFallback, getGitHubPublicFork } from '@/admin/github';
import {
getGitHubMetaWithFallback,
getGitHubPublicFork,
} from '@/utility/github';
import { TEMPLATE_REPO_OWNER, TEMPLATE_REPO_NAME } from '@/app-core/config';
describe('GitHub', () => {
@ -8,7 +11,7 @@ describe('GitHub', () => {
repo: TEMPLATE_REPO_NAME,
});
expect(meta).toBeDefined();
expect(meta.url).toBeDefined();
expect(meta.urlRepo).toBeDefined();
expect(meta.isForkedFromBase).toEqual(false);
expect(meta.label).toBeDefined();
expect(meta.description).toBeDefined();
@ -26,7 +29,7 @@ describe('GitHub', () => {
repo: 'nonexistent',
});
expect(meta).toBeDefined();
expect(meta.url).toBeDefined();
expect(meta.urlRepo).toBeDefined();
expect(meta.isForkedFromBase).toEqual(false);
expect(meta.label).toEqual('Unknown');
expect(meta.description).toEqual('Unknown');
@ -38,7 +41,7 @@ describe('GitHub', () => {
repo: 'bad text for a url.com',
});
expect(meta).toBeDefined();
expect(meta.url).toBeDefined();
expect(meta.urlRepo).toBeDefined();
expect(meta.isForkedFromBase).toEqual(false);
expect(meta.label).toEqual('Unknown');
expect(meta.description).toEqual('Unknown');

View File

@ -1,15 +0,0 @@
import { Suspense } from 'react';
import GitHubForkStatusBadgeClient from './GitHubForkStatusBadgeClient';
import GitHubForkStatusBadgeServer from './GitHubForkStatusBadgeServer';
import { IS_DEVELOPMENT } from '@/app-core/config';
export default function GitHubForkStatusBadge() {
return IS_DEVELOPMENT
? <GitHubForkStatusBadgeClient
label="Local"
tooltip="GitHub status unknown when running locally."
/>
: <Suspense>
<GitHubForkStatusBadgeServer />
</Suspense>;
}

View File

@ -1,68 +0,0 @@
import Spinner from '@/components/Spinner';
import Tooltip from '@/components/Tooltip';
import clsx from 'clsx/lite';
import { ReactNode } from 'react';
import { BiLogoGithub } from 'react-icons/bi';
export default function GitHubForkStatusBadgeClient({
label,
style = 'mono',
tooltip,
}: {
label?: ReactNode
style?: 'info' |'success' | 'warning' | 'error' | 'mono'
tooltip?: ReactNode
}) {
const classNameForStyle = () => {
switch (style) {
case 'info': return clsx(
'text-blue-600 hover:text-blue-600',
'dark:text-blue-400 dark:hover:text-blue-400',
'bg-blue-100/40 dark:bg-blue-900/25',
'border-blue-300/40 dark:border-blue-900/50',
);
case 'success': return clsx(
'text-green-700 hover:text-green-700',
'dark:text-green-400 dark:hover:text-green-400',
'bg-green-100/40 dark:bg-green-900/25',
'border-green-300/40 dark:border-green-900/50',
);
case 'warning': return clsx(
'text-amber-800/90 hover:text-amber-800/90',
'dark:text-amber-400 dark:hover:text-amber-400',
'bg-amber-100/40 dark:bg-amber-900/25',
'border-amber-300/40 dark:border-amber-900/50',
);
case 'error': return clsx(
'text-red-700/90 hover:text-red-700/90',
'dark:text-red-400 dark:hover:text-red-400',
'bg-red-100/20 dark:bg-red-900/25',
'border-red-300/40 dark:border-red-900/50',
);
default: return clsx(
'text-main',
'bg-white dark:bg-transparent',
'border-main',
);
}
};
return (
<Tooltip content={tooltip}>
<div className={clsx(
'opacity-0 transition-opacity animate-fade-in',
'inline-flex items-center gap-2',
'border transition-colors',
'select-none',
'pl-[4.5px] pr-2.5 py-[3px]',
'rounded-full shadow-xs',
classNameForStyle(),
)}>
{!label
? <Spinner className="translate-x-[3px] translate-y-[0.5px]" />
: <BiLogoGithub size={17} />}
{label ?? 'Checking'}
</div>
</Tooltip>
);
}

View File

@ -1,60 +0,0 @@
import GitHubForkStatusBadgeClient from './GitHubForkStatusBadgeClient';
import {
VERCEL_GIT_BRANCH,
VERCEL_GIT_REPO_OWNER,
VERCEL_GIT_REPO_SLUG,
VERCEL_GIT_COMMIT_SHA,
} from '@/app-core/config';
import { getGitHubMetaWithFallback, getGitHubUrlRepo } from '.';
export default async function GitHubForkStatusBadgeServer() {
const owner = VERCEL_GIT_REPO_OWNER;
const repo = VERCEL_GIT_REPO_SLUG;
const branch = VERCEL_GIT_BRANCH;
const commit = VERCEL_GIT_COMMIT_SHA;
const {
isForkedFromBase,
isBaseRepo,
isBehind,
label,
description,
didError,
} = await getGitHubMetaWithFallback({ owner, repo, branch, commit });
const repoLink = (text: string) =>
<a
href={getGitHubUrlRepo({ owner, repo })}
target="_blank"
className="underline hover:no-underline hover:text-main"
>
{text}
</a>;
const isBehindContent = <>
{' '}
{repoLink('Sync on GitHub')} for latest updates.
</>;
const didErrorContent = <>
{' '}
Could not connect to {repoLink('GitHub')}.
</>;
return isForkedFromBase || isBaseRepo
? <GitHubForkStatusBadgeClient {...{
label,
tooltip: <>
{description}
{didError
? didErrorContent
: isBehind
? isBehindContent
: null}
</>,
style: didError || isBehind === undefined || isBehind
? 'info'
: 'mono',
}} />
: null;
}

View File

@ -18,7 +18,7 @@ import {
VERCEL_GIT_REPO_OWNER,
VERCEL_GIT_REPO_SLUG,
} from '@/app-core/config';
import { getGitHubMetaWithFallback } from '../github';
import { getGitHubMetaWithFallback } from '../../utility/github';
import { OUTDATED_THRESHOLD } from '@/photo';
const BASIC_PHOTO_INSTALLATION_COUNT = 32;

View File

@ -11,7 +11,7 @@ import { HiOutlinePhotograph } from 'react-icons/hi';
import { MdAspectRatio } from 'react-icons/md';
import { PiWarningBold } from 'react-icons/pi';
import { TbCone, TbSparkles } from 'react-icons/tb';
import { getGitHubMetaWithFallback } from '../github';
import { getGitHubMetaWithFallback } from '../../utility/github';
import { BiGitBranch, BiGitCommit, BiLogoGithub } from 'react-icons/bi';
import {
TEMPLATE_REPO_BRANCH,

View File

@ -1,17 +1,8 @@
import AdminAppInsights from '@/admin/insights/AdminAppInsights';
import AdminInfoPage from '@/admin/AdminInfoPage';
import GitHubForkStatusBadge from '@/admin/github/GitHubForkStatusBadge';
import {
IS_DEVELOPMENT,
IS_VERCEL_GIT_PROVIDER_GITHUB,
} from '@/app-core/config';
export default async function AdminInsightsPage() {
return <AdminInfoPage
title="App Insights"
accessory={(IS_VERCEL_GIT_PROVIDER_GITHUB || IS_DEVELOPMENT) &&
<GitHubForkStatusBadge />}
>
return <AdminInfoPage title="App Insights">
<AdminAppInsights />
</AdminInfoPage>;
}

View File

@ -121,14 +121,12 @@ const isRepoBaseRepo = ({ owner, repo }: RepoParams) =>
owner?.toLowerCase() === TEMPLATE_REPO_OWNER &&
repo?.toLowerCase() === TEMPLATE_REPO_NAME;
export const getGitHubPublicFork = async (
params?: RepoParams,
): Promise<RepoParams> => {
const response = await fetch(getGitHubApiForksUrl(params), FETCH_CONFIG);
export const getGitHubPublicFork = async (): Promise<RepoParams> => {
const response = await fetch(getGitHubApiForksUrl(), FETCH_CONFIG);
const fork = (await response.json())[0];
return {
owner: fork.owner.login,
repo: fork.name,
owner: fork?.owner.login,
repo: fork?.name,
};
};