Skip to content

Commit d4e6f3c

Browse files
fix: add icon for github mirrors
1 parent 2709a8e commit d4e6f3c

3 files changed

Lines changed: 50 additions & 5 deletions

File tree

packages/apps/explorer/src/components/GithubImportCard.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '@ps/daemon-client'
1414
import type { Database } from '@ps/schema'
1515
import { useTheme } from '../ui/theme-context'
16+
import { FaGithub } from 'react-icons/fa'
1617

1718
export const REPO_IMPORT_EVENT = '__powergit:repo-imported'
1819

@@ -111,6 +112,11 @@ export function GithubImportCard(): React.JSX.Element | null {
111112
job?.branch ??
112113
null
113114

115+
const isGithubMirrorTarget =
116+
typeof resultOrgId === 'string' && resultOrgId.startsWith('gh-') && resultOrgId.length > 3
117+
const displayTargetOrgId =
118+
typeof resultOrgId === 'string' ? (isGithubMirrorTarget ? resultOrgId.slice(3) : resultOrgId) : ''
119+
114120
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
115121
event.preventDefault()
116122
setError(null)
@@ -249,7 +255,17 @@ export function GithubImportCard(): React.JSX.Element | null {
249255
{showSummary && resultOrgId && resultRepoId ? (
250256
<div className={`${summaryContainerClass} mt-3 flex flex-wrap items-center gap-2`} data-testid="import-summary">
251257
<div className={isDark ? 'font-medium text-slate-100' : 'font-medium text-slate-800'}>
252-
Target: <code>{resultOrgId}/{resultRepoId}</code>
258+
Target:{' '}
259+
<span className="inline-flex items-center gap-1">
260+
{isGithubMirrorTarget ? (
261+
<FaGithub
262+
className={`${isDark ? 'text-slate-200' : 'text-slate-500'} text-[14px]`}
263+
title="GitHub mirror"
264+
aria-hidden
265+
/>
266+
) : null}
267+
<code>{displayTargetOrgId}/{resultRepoId}</code>
268+
</span>
253269
</div>
254270
<div className={isDark ? 'text-slate-200' : 'text-slate-600'}>
255271
Status: <span className="uppercase tracking-wide text-[11px]">{displayStatus}</span>

packages/apps/explorer/src/routes/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { Database } from '@ps/schema'
99
import { useTheme } from '../ui/theme-context'
1010
import { deleteDaemonRepo, isDaemonPreferred } from '@ps/daemon-client'
1111
import { IoTrashOutline } from 'react-icons/io5'
12+
import { FaGithub } from 'react-icons/fa'
1213
import { InlineSpinner } from '../components/InlineSpinner'
1314

1415
type HomeSearch = {
@@ -280,6 +281,8 @@ export function Home() {
280281
{sortedSummaries.map((repo) => {
281282
const branchCount = Array.from(repo.branches).filter((name) => name && name !== 'HEAD').length
282283
const importStatus = repo.status?.trim().toLowerCase() ?? null
284+
const isGithubMirror = repo.orgId.startsWith('gh-') && repo.orgId.length > 3
285+
const displayOrgId = isGithubMirror ? repo.orgId.slice(3) : repo.orgId
283286
const branchSummary = (() => {
284287
if (branchCount > 0) return `${branchCount} branch${branchCount === 1 ? '' : 'es'}`
285288
if (importStatus === 'queued') return 'Import queued'
@@ -293,9 +296,20 @@ export function Home() {
293296
<li key={repoKey} className={repoCardBase}>
294297
<div className="space-y-1">
295298
<div className={`text-base font-semibold ${isDark ? 'text-slate-100' : 'text-slate-900'}`}>
296-
{repo.orgId}
297-
<span className="text-slate-400">/</span>
298-
{repo.repoId}
299+
<span className="inline-flex items-center gap-2">
300+
{isGithubMirror ? (
301+
<FaGithub
302+
className={`${isDark ? 'text-slate-300' : 'text-slate-500'} text-[16px]`}
303+
title="GitHub mirror"
304+
aria-hidden
305+
/>
306+
) : null}
307+
<span>
308+
{displayOrgId}
309+
<span className="text-slate-400">/</span>
310+
{repo.repoId}
311+
</span>
312+
</span>
299313
</div>
300314
<div className={`text-xs ${isDark ? 'text-slate-400' : 'text-slate-500'}`}>
301315
{branchSummary} · Updated {formatTimestamp(repo.updatedAt)}

packages/apps/explorer/src/routes/org.$orgId.repo.$repoId.index.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useCollections } from '@tsdb/collections'
66
import { useLiveQuery } from '@tanstack/react-db'
77
import type { Database } from '@ps/schema'
88
import { useTheme } from '../ui/theme-context'
9+
import { FaGithub } from 'react-icons/fa'
910

1011
export const Route = createFileRoute('/org/$orgId/repo/$repoId/' as any)({
1112
component: RepoOverview,
@@ -15,6 +16,8 @@ function RepoOverview() {
1516
const { orgId, repoId } = Route.useParams()
1617
const { theme } = useTheme()
1718
const isDark = theme === 'dark'
19+
const isGithubMirror = orgId.startsWith('gh-') && orgId.length > 3
20+
const displayOrgId = isGithubMirror ? orgId.slice(3) : orgId
1821
useRepoStreams(orgId, repoId)
1922
const { refs } = useCollections()
2023

@@ -48,7 +51,19 @@ function RepoOverview() {
4851
return (
4952
<div className="mx-auto max-w-6xl space-y-4">
5053
<h2 className={headingClass}>
51-
Repo: {orgId}/{repoId}
54+
Repo:{' '}
55+
<span className="inline-flex items-center gap-2">
56+
{isGithubMirror ? (
57+
<FaGithub
58+
className={`${isDark ? 'text-slate-300' : 'text-slate-500'} text-[18px]`}
59+
title="GitHub mirror"
60+
aria-hidden
61+
/>
62+
) : null}
63+
<span>
64+
{displayOrgId}/{repoId}
65+
</span>
66+
</span>
5267
</h2>
5368
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
5469
<div className={cardClass}>

0 commit comments

Comments
 (0)