feat(tabby-ui): add endpoint url to home page
parent
fc93cf80b4
commit
9d607956f5
|
|
@ -7,6 +7,7 @@ import { useWorkers } from '@/lib/hooks/use-workers'
|
||||||
import { useAuthenticatedGraphQLQuery, useGraphQLForm } from '@/lib/tabby/gql'
|
import { useAuthenticatedGraphQLQuery, useGraphQLForm } from '@/lib/tabby/gql'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { IconRefresh } from '@/components/ui/icons'
|
import { IconRefresh } from '@/components/ui/icons'
|
||||||
|
import { Separator } from '@/components/ui/separator'
|
||||||
import { CopyButton } from '@/components/copy-button'
|
import { CopyButton } from '@/components/copy-button'
|
||||||
|
|
||||||
import WorkerCard from './worker-card'
|
import WorkerCard from './worker-card'
|
||||||
|
|
@ -23,6 +24,10 @@ const resetRegistrationTokenDocument = graphql(/* GraphQL */ `
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
function toBadgeString(str: string) {
|
||||||
|
return encodeURIComponent(str.replaceAll('-', '--'))
|
||||||
|
}
|
||||||
|
|
||||||
export default function Workers() {
|
export default function Workers() {
|
||||||
const { data: healthInfo } = useHealth()
|
const { data: healthInfo } = useHealth()
|
||||||
const workers = useWorkers()
|
const workers = useWorkers()
|
||||||
|
|
@ -41,6 +46,23 @@ export default function Workers() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full flex-col gap-3 p-4 lg:p-16">
|
<div className="flex w-full flex-col gap-3 p-4 lg:p-16">
|
||||||
|
<h1>
|
||||||
|
<span className="font-bold">Congratulations</span>, your tabby instance
|
||||||
|
is up!
|
||||||
|
</h1>
|
||||||
|
<span className="flex flex-wrap gap-1">
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
href={`https://github.com/TabbyML/tabby/releases/tag/${healthInfo.version.git_describe}`}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={`https://img.shields.io/badge/version-${toBadgeString(
|
||||||
|
healthInfo.version.git_describe
|
||||||
|
)}-green`}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
<Separator />
|
||||||
{!!registrationTokenRes?.registrationToken && (
|
{!!registrationTokenRes?.registrationToken && (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
Registeration token:
|
Registeration token:
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { graphql } from '@/lib/gql/generates'
|
import { graphql } from '@/lib/gql/generates'
|
||||||
import { useHealth } from '@/lib/hooks/use-health'
|
import { useHealth } from '@/lib/hooks/use-health'
|
||||||
import { useAuthenticatedGraphQLQuery } from '@/lib/tabby/gql'
|
import { useAuthenticatedGraphQLQuery } from '@/lib/tabby/gql'
|
||||||
import { Separator } from '@/components/ui/separator'
|
import {
|
||||||
|
CardContent,
|
||||||
|
CardFooter,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle
|
||||||
|
} from '@/components/ui/card'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
import { CopyButton } from '@/components/copy-button'
|
import { CopyButton } from '@/components/copy-button'
|
||||||
import SlackDialog from '@/components/slack-dialog'
|
import SlackDialog from '@/components/slack-dialog'
|
||||||
|
|
||||||
|
|
@ -16,10 +24,6 @@ export default function Home() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function toBadgeString(str: string) {
|
|
||||||
return encodeURIComponent(str.replaceAll('-', '--'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const meQuery = graphql(/* GraphQL */ `
|
const meQuery = graphql(/* GraphQL */ `
|
||||||
query MeQuery {
|
query MeQuery {
|
||||||
me {
|
me {
|
||||||
|
|
@ -31,46 +35,48 @@ const meQuery = graphql(/* GraphQL */ `
|
||||||
function MainPanel() {
|
function MainPanel() {
|
||||||
const { data: healthInfo } = useHealth()
|
const { data: healthInfo } = useHealth()
|
||||||
const { data } = useAuthenticatedGraphQLQuery(meQuery)
|
const { data } = useAuthenticatedGraphQLQuery(meQuery)
|
||||||
|
const [origin, setOrigin] = useState('')
|
||||||
|
useEffect(() => {
|
||||||
|
setOrigin(new URL(window.location.href).origin)
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!healthInfo || !data) return
|
if (!healthInfo || !data) return
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full flex-col gap-3">
|
<div>
|
||||||
<h1>
|
<CardHeader>
|
||||||
<span className="font-bold">Congratulations</span>, your tabby instance
|
<CardTitle>Getting Started</CardTitle>
|
||||||
is up!
|
</CardHeader>
|
||||||
</h1>
|
<CardContent className="flex max-w-[420px] flex-col gap-2">
|
||||||
<span className="flex flex-wrap gap-1">
|
<span className="flex items-center justify-between gap-2">
|
||||||
<a
|
<span>Endpoint URL</span>
|
||||||
target="_blank"
|
<span className="flex items-center">
|
||||||
href={`https://github.com/TabbyML/tabby/releases/tag/${healthInfo.version.git_describe}`}
|
<Input value={origin} />
|
||||||
>
|
<CopyButton value={origin} />
|
||||||
<img
|
</span>
|
||||||
src={`https://img.shields.io/badge/version-${toBadgeString(
|
</span>
|
||||||
healthInfo.version.git_describe
|
|
||||||
)}-green`}
|
<span className="flex items-center justify-between gap-2">
|
||||||
/>
|
<span>Token</span>
|
||||||
</a>
|
<span className="flex items-center">
|
||||||
</span>
|
<Input value={data.me.authToken} />
|
||||||
<Separator />
|
<CopyButton value={data.me.authToken} />
|
||||||
<div className="flex items-center">
|
</span>
|
||||||
<span className="mr-2">Token:</span>
|
</span>
|
||||||
<code className="rounded-lg text-sm text-red-600">
|
</CardContent>
|
||||||
{data.me.authToken}
|
<CardFooter>
|
||||||
</code>
|
<span>
|
||||||
<CopyButton value={data.me.authToken} />
|
Use informations above for IDE extensions / plugins configuration, see{' '}
|
||||||
</div>
|
<a
|
||||||
<p>
|
className="underline"
|
||||||
Use credentials above for IDE extensions / plugins authentication, see{' '}
|
target="_blank"
|
||||||
<a
|
href="https://tabby.tabbyml.com/docs/extensions/configurations#server"
|
||||||
className="underline"
|
>
|
||||||
target="_blank"
|
documentation website
|
||||||
href="https://tabby.tabbyml.com/docs/extensions/configurations#server"
|
</a>{' '}
|
||||||
>
|
for details
|
||||||
configurations
|
</span>
|
||||||
</a>{' '}
|
</CardFooter>
|
||||||
for details
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue