forked from defunkt/toes
Show tunnel URL for public repos in git clone hints
This commit is contained in:
parent
0e943bda2a
commit
946cdb1794
|
|
@ -157,6 +157,7 @@ interface RepoListPageProps {
|
||||||
baseUrl: string
|
baseUrl: string
|
||||||
external: boolean
|
external: boolean
|
||||||
repos: Array<{ name: string; commits: boolean; branch: string; visibility: Visibility }>
|
repos: Array<{ name: string; commits: boolean; branch: string; visibility: Visibility }>
|
||||||
|
tunnelUrl?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Visibility = 'public' | 'private'
|
type Visibility = 'public' | 'private'
|
||||||
|
|
@ -543,7 +544,7 @@ function AppRepo({ appName, baseUrl, branch, exists, commits }: AppRepoProps) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function RepoListPage({ baseUrl, external, repos }: RepoListPageProps) {
|
function RepoListPage({ baseUrl, external, repos, tunnelUrl }: RepoListPageProps) {
|
||||||
return (
|
return (
|
||||||
<Layout title="Git">
|
<Layout title="Git">
|
||||||
{!external && (
|
{!external && (
|
||||||
|
|
@ -576,6 +577,11 @@ function RepoListPage({ baseUrl, external, repos }: RepoListPageProps) {
|
||||||
<HelpText style="margin: 4px 0 0; font-size: 12px">
|
<HelpText style="margin: 4px 0 0; font-size: 12px">
|
||||||
git clone {baseUrl}/{name}
|
git clone {baseUrl}/{name}
|
||||||
</HelpText>
|
</HelpText>
|
||||||
|
{!external && tunnelUrl && visibility === 'public' && (
|
||||||
|
<HelpText style="margin: 2px 0 0; font-size: 12px">
|
||||||
|
git clone {tunnelUrl}/{name}
|
||||||
|
</HelpText>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex; gap: 8px; align-items: center">
|
<div style="display: flex; gap: 8px; align-items: center">
|
||||||
{!external && (
|
{!external && (
|
||||||
|
|
@ -789,7 +795,19 @@ app.get('/', async c => {
|
||||||
? repoData.filter(r => r.visibility === 'public')
|
? repoData.filter(r => r.visibility === 'public')
|
||||||
: repoData
|
: repoData
|
||||||
|
|
||||||
return c.html(<RepoListPage baseUrl={baseUrl} external={external} repos={filtered} />)
|
// Fetch tunnel URL for the git tool so we can show it for public repos
|
||||||
|
let tunnelUrl: string | undefined
|
||||||
|
if (!external) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${TOES_URL}/api/apps/git`)
|
||||||
|
if (res.ok) {
|
||||||
|
const info = await res.json() as { tunnelUrl?: string }
|
||||||
|
tunnelUrl = info.tunnelUrl
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.html(<RepoListPage baseUrl={baseUrl} external={external} repos={filtered} tunnelUrl={tunnelUrl} />)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default app.defaults
|
export default app.defaults
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user