mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(frontend): switch servers from the home page header
Replace the read-only connection status with the server switcher, so the header names the selected linked server and can change servers in place.
This commit is contained in:
1 parent
c4bb104cc0
commit
cbdd252d7a
4 files changed
+32
-93
No files matched your search
@@ -20,10 +20,10 @@ import { cn } from '@/lib/utils'
|
||||
|
||||
const LOCAL_SERVER_LABEL = 'OC Manager'
|
||||
|
||||
export type LinkedServersVariant = 'sidebar' | 'rail' | 'sheet'
|
||||
export type LinkedServersVariant = 'sidebar' | 'rail' | 'sheet' | 'header'
|
||||
|
||||
interface LinkedServersNavProps {
|
||||
/** `sidebar` renders the full-width trigger row, `rail` the collapsed icon button, `sheet` the mobile sheet row. */
|
||||
/** `sidebar` renders the full-width trigger row, `rail` the collapsed icon button, `sheet` the mobile sheet row, `header` a compact page-header trigger. */
|
||||
variant?: LinkedServersVariant
|
||||
}
|
||||
|
||||
@@ -218,7 +218,9 @@ export function LinkedServersNav({ variant = 'sidebar' }: LinkedServersNavProps)
|
||||
'flex items-center rounded-md text-sm text-foreground transition-colors duration-150',
|
||||
'hover:bg-accent/50',
|
||||
'focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
||||
isRail ? 'mx-auto h-9 w-9 justify-center' : 'h-9 w-full gap-2 px-2',
|
||||
isRail && 'mx-auto h-9 w-9 justify-center',
|
||||
variant === 'header' && 'h-8 min-w-0 max-w-[45vw] gap-2 px-2 sm:max-w-xs',
|
||||
(variant === 'sidebar' || variant === 'sheet') && 'h-9 w-full gap-2 px-2',
|
||||
)}
|
||||
>
|
||||
<span className="relative flex shrink-0">
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import type { OpenCodeServerStatus } from '@opencode-manager/shared/schemas'
|
||||
|
||||
interface ConnectionStatusProps {
|
||||
status?: OpenCodeServerStatus
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection indicator for a linked server: checking, unknown, unreachable with its error, or
|
||||
* connected with the server version.
|
||||
*/
|
||||
export function ConnectionStatus({ status, isLoading }: ConnectionStatusProps) {
|
||||
if (isLoading) {
|
||||
return <span className="text-xs text-muted-foreground">Checking connection...</span>
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
return (
|
||||
<span className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
<span className="h-2 w-2 rounded-full bg-muted-foreground/50" />
|
||||
Unknown
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
if (!status.connected) {
|
||||
return (
|
||||
<span className="flex items-center gap-1.5 text-xs text-destructive" title={status.error ?? undefined}>
|
||||
<span className="h-2 w-2 rounded-full bg-destructive" />
|
||||
Unreachable
|
||||
{status.error ? <span className="text-muted-foreground">· {status.error}</span> : null}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="flex items-center gap-1.5 text-xs text-success">
|
||||
<span className="h-2 w-2 rounded-full bg-success" />
|
||||
Connected
|
||||
{status.version ? <span className="text-muted-foreground">· v{status.version}</span> : null}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user