fix(ui): improve cliproxy dashboard layout and dropdown styling

This commit is contained in:
kaitranntt committed 2025-12-08 00:28:06 -05:00
1 parent 4dc17fac4f
commit 10d05502f3
3 files changed
+107 -70

No files matched your search

+21 -9
View File
@@ -44,6 +44,7 @@ export function CliproxyTable({ data }: CliproxyTableProps) {
{ {
accessorKey: 'name', accessorKey: 'name',
header: 'Name', header: 'Name',
cell: ({ row }) => <span className="font-medium">{row.original.name}</span>,
}, },
{ {
accessorKey: 'provider', accessorKey: 'provider',
@@ -56,11 +57,11 @@ export function CliproxyTable({ data }: CliproxyTableProps) {
cell: ({ row }) => { cell: ({ row }) => {
const account = row.original.account; const account = row.original.account;
if (!account) { if (!account) {
return <span className="text-muted-foreground text-xs">default</span>; return <span className="text-muted-foreground text-xs italic">default</span>;
} }
return ( return (
<Badge variant="secondary" className="text-xs font-normal"> <Badge variant="secondary" className="text-xs font-normal">
<User className="w-3 h-3 mr-1" /> <User className="w-3 h-3 mr-1 opacity-70" />
{account} {account}
</Badge> </Badge>
); );
@@ -69,20 +70,27 @@ export function CliproxyTable({ data }: CliproxyTableProps) {
{ {
accessorKey: 'settings', accessorKey: 'settings',
header: 'Settings Path', header: 'Settings Path',
cell: ({ row }) => (
<code className="text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground">
{row.original.settings || `config.cliproxy.${row.original.name}`}
</code>
),
}, },
{ {
id: 'actions', id: 'actions',
header: 'Actions', header: 'Actions',
cell: ({ row }) => ( cell: ({ row }) => (
<div className="flex justify-end">
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm"> <Button variant="ghost" size="sm" className="h-8 w-8 p-0">
<span className="sr-only">Open menu</span>
<MoreHorizontal className="w-4 h-4" /> <MoreHorizontal className="w-4 h-4" />
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="end"> <DropdownMenuContent align="end" className="bg-white dark:bg-zinc-950">
<DropdownMenuItem <DropdownMenuItem
className="text-red-600" className="text-red-600 focus:text-red-600 focus:bg-red-50 dark:focus:bg-red-950/30"
onClick={() => deleteMutation.mutate(row.original.name)} onClick={() => deleteMutation.mutate(row.original.name)}
> >
<Trash2 className="w-4 h-4 mr-2" /> <Trash2 className="w-4 h-4 mr-2" />
@@ -90,6 +98,7 @@ export function CliproxyTable({ data }: CliproxyTableProps) {
</DropdownMenuItem> </DropdownMenuItem>
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
</div>
), ),
}, },
]; ];
@@ -103,16 +112,19 @@ export function CliproxyTable({ data }: CliproxyTableProps) {
if (data.length === 0) { if (data.length === 0) {
return ( return (
<div className="text-center py-8 text-muted-foreground"> <div className="text-center py-12 border rounded-lg bg-muted/5 border-dashed">
No CLIProxy variants found. Create one to use OAuth-based providers. <div className="text-muted-foreground text-sm">No CLIProxy variants found.</div>
<div className="text-xs text-muted-foreground mt-1">
Create one to use OAuth-based providers with specific account configurations.
</div>
</div> </div>
); );
} }
return ( return (
<div className="border rounded-md"> <div className="border rounded-md overflow-hidden bg-card">
<Table> <Table>
<TableHeader> <TableHeader className="bg-muted/50">
{table.getHeaderGroups().map((headerGroup) => ( {table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}> <TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => ( {headerGroup.headers.map((header) => (
+1 -1
View File
@@ -31,7 +31,7 @@ function DropdownMenuContent({
data-slot="dropdown-menu-content" data-slot="dropdown-menu-content"
sideOffset={sideOffset} sideOffset={sideOffset}
className={cn( className={cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md', 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md bg-white dark:bg-zinc-950',
className className
)} )}
{...props} {...props}
+85 -60
View File
@@ -7,12 +7,12 @@
import { useState } from 'react'; import { useState } from 'react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge'; import { Badge } from '@/components/ui/badge';
import { Card, CardContent } from '@/components/ui/card';
import { import {
DropdownMenu, DropdownMenu,
DropdownMenuContent, DropdownMenuContent,
DropdownMenuItem, DropdownMenuItem,
DropdownMenuTrigger, DropdownMenuTrigger,
DropdownMenuSeparator,
} from '@/components/ui/dropdown-menu'; } from '@/components/ui/dropdown-menu';
import { Plus, Check, X, User, ChevronDown, Star, Trash2 } from 'lucide-react'; import { Plus, Check, X, User, ChevronDown, Star, Trash2 } from 'lucide-react';
import { CliproxyTable } from '@/components/cliproxy-table'; import { CliproxyTable } from '@/components/cliproxy-table';
@@ -40,10 +40,10 @@ function AccountBadge({
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<button <button
className={`inline-flex items-center gap-1.5 px-2 py-1 text-xs rounded-md border transition-colors hover:bg-muted/50 ${ className={`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full border transition-colors hover:bg-muted/80 ${
account.isDefault account.isDefault
? 'border-primary/30 bg-primary/5 text-primary' ? 'border-primary/30 bg-primary/10 text-primary font-medium'
: 'border-muted bg-muted/20' : 'border-muted bg-muted/40'
}`} }`}
> >
<User className="w-3 h-3" /> <User className="w-3 h-3" />
@@ -52,16 +52,15 @@ function AccountBadge({
<ChevronDown className="w-3 h-3 opacity-50" /> <ChevronDown className="w-3 h-3 opacity-50" />
</button> </button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="start" className="w-48"> <DropdownMenuContent align="start" className="w-56">
<div className="px-2 py-1.5 text-xs text-muted-foreground"> <div className="px-2 py-1.5 text-xs text-muted-foreground bg-muted/30 -mx-1 -mt-1 mb-1 border-b">
<div className="font-medium text-foreground mb-0.5 truncate">
{account.email || account.id} {account.email || account.id}
{account.lastUsedAt && (
<div className="mt-0.5">
Last used: {new Date(account.lastUsedAt).toLocaleDateString()}
</div> </div>
{account.lastUsedAt && (
<div>Last used: {new Date(account.lastUsedAt).toLocaleDateString()}</div>
)} )}
</div> </div>
<DropdownMenuSeparator />
{!account.isDefault && ( {!account.isDefault && (
<DropdownMenuItem onClick={onSetDefault}> <DropdownMenuItem onClick={onSetDefault}>
<Star className="w-4 h-4 mr-2" /> <Star className="w-4 h-4 mr-2" />
@@ -69,7 +68,7 @@ function AccountBadge({
</DropdownMenuItem> </DropdownMenuItem>
)} )}
<DropdownMenuItem <DropdownMenuItem
className="text-red-600 focus:text-red-600" className="text-red-600 focus:text-red-600 focus:bg-red-50 dark:focus:bg-red-950/30"
onClick={onRemove} onClick={onRemove}
disabled={isRemoving} disabled={isRemoving}
> >
@@ -81,7 +80,7 @@ function AccountBadge({
); );
} }
function ProviderCard({ function ProviderRow({
status, status,
setDefaultMutation, setDefaultMutation,
removeMutation, removeMutation,
@@ -91,35 +90,35 @@ function ProviderCard({
removeMutation: ReturnType<typeof useRemoveAccount>; removeMutation: ReturnType<typeof useRemoveAccount>;
}) { }) {
const accounts = status.accounts || []; const accounts = status.accounts || [];
const hasMultipleAccounts = accounts.length > 1;
return ( return (
<div className="flex flex-col sm:flex-row sm:items-center justify-between p-4 border-b last:border-0 hover:bg-muted/5 transition-colors gap-4">
<div className="flex items-center gap-4 min-w-[180px]">
<div <div
className={`p-4 rounded-lg border ${ className={`flex items-center justify-center w-8 h-8 rounded-full ${
status.authenticated ? 'border-green-500/30 bg-green-500/5' : 'border-muted bg-muted/5' status.authenticated
? 'bg-green-500/10 text-green-600 dark:text-green-400'
: 'bg-muted text-muted-foreground'
}`} }`}
> >
<div className="flex items-center justify-between"> {status.authenticated ? <Check className="w-5 h-5" /> : <X className="w-5 h-5" />}
<div className="flex items-center gap-2">
{status.authenticated ? (
<Check className="w-4 h-4 text-green-500" />
) : (
<X className="w-4 h-4 text-muted-foreground" />
)}
<span className="font-medium">{status.displayName}</span>
</div> </div>
<div>
<div className="font-medium flex items-center gap-2">
{status.displayName}
{accounts.length > 0 && ( {accounts.length > 0 && (
<Badge variant="secondary" className="text-xs"> <Badge variant="secondary" className="text-[10px] h-5 px-1.5 font-normal">
{accounts.length} account{accounts.length !== 1 ? 's' : ''} {accounts.length}
</Badge> </Badge>
)} )}
</div> </div>
<div className="text-xs text-muted-foreground mt-0.5">{status.provider}</div>
</div>
</div>
{status.authenticated ? ( <div className="flex-1 flex items-center gap-2 flex-wrap">
<div className="mt-2"> {status.authenticated && accounts.length > 0 ? (
{accounts.length > 0 ? ( accounts.map((account) => (
<div className="flex flex-wrap gap-1.5">
{accounts.map((account) => (
<AccountBadge <AccountBadge
key={account.id} key={account.id}
account={account} account={account}
@@ -137,34 +136,40 @@ function ProviderCard({
} }
isRemoving={removeMutation.isPending} isRemoving={removeMutation.isPending}
/> />
))} ))
</div>
) : ( ) : (
<div className="text-sm text-muted-foreground"> <div className="text-sm text-muted-foreground italic">
Authenticated {status.authenticated
{status.lastAuth && ( ? 'Authenticated (No specific accounts tracked)'
<span className="ml-1">({new Date(status.lastAuth).toLocaleDateString()})</span> : 'Not authenticated'}
)}
</div> </div>
)} )}
{hasMultipleAccounts && ( </div>
<div className="mt-2 text-xs text-muted-foreground">
Click account to manage. Star = default. <div className="flex items-center gap-2">
{!status.authenticated && (
<div className="text-xs font-mono bg-muted px-2 py-1 rounded text-muted-foreground select-all">
ccs {status.provider} --auth
</div> </div>
)} )}
<div className="mt-2 text-xs text-muted-foreground"> {status.authenticated && (
Add account: <code className="bg-muted px-1 rounded">ccs {status.provider} --auth</code> <Button
</div> variant="outline"
</div> size="sm"
) : ( className="h-7 text-xs gap-1"
<div className="mt-1 text-sm text-muted-foreground"> onClick={() => {
Not authenticated // This is a placeholder since we can't actually run the auth command from UI easily without a terminal
<span className="block text-xs mt-1"> // But we can show the command to run
Run: <code className="bg-muted px-1 rounded">ccs {status.provider} --auth</code> navigator.clipboard.writeText(`ccs ${status.provider} --auth`);
</span> }}
</div> title="Copy auth command"
>
<Plus className="w-3 h-3" />
Add Account
</Button>
)} )}
</div> </div>
</div>
); );
} }
@@ -176,12 +181,12 @@ export function CliproxyPage() {
const removeMutation = useRemoveAccount(); const removeMutation = useRemoveAccount();
return ( return (
<div className="p-6 space-y-6"> <div className="p-6 max-w-6xl mx-auto space-y-8">
<div className="flex items-center justify-between"> <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div> <div>
<h1 className="text-2xl font-bold">CLIProxy</h1> <h1 className="text-2xl font-bold tracking-tight">CLIProxy</h1>
<p className="text-sm text-muted-foreground mt-1"> <p className="text-sm text-muted-foreground mt-1">
Manage OAuth-based provider variants with multi-account support Manage OAuth-based provider variants and multi-account configurations
</p> </p>
</div> </div>
<Button onClick={() => setDialogOpen(true)}> <Button onClick={() => setDialogOpen(true)}>
@@ -191,14 +196,24 @@ export function CliproxyPage() {
</div> </div>
{/* Built-in Profiles with Account Management */} {/* Built-in Profiles with Account Management */}
<div className="space-y-4">
<div> <div>
<h2 className="text-lg font-semibold mb-3">Built-in Profiles & Accounts</h2> <h2 className="text-lg font-semibold tracking-tight">Built-in Providers</h2>
<p className="text-sm text-muted-foreground">
Manage authentication status and accounts for built-in providers.
</p>
</div>
<Card>
<CardContent className="p-0">
{authLoading ? ( {authLoading ? (
<div className="text-muted-foreground">Loading auth status...</div> <div className="p-8 text-center text-muted-foreground">
Loading authentication status...
</div>
) : ( ) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3"> <div className="flex flex-col">
{authData?.authStatus.map((status) => ( {authData?.authStatus.map((status) => (
<ProviderCard <ProviderRow
key={status.provider} key={status.provider}
status={status} status={status}
setDefaultMutation={setDefaultMutation} setDefaultMutation={setDefaultMutation}
@@ -207,11 +222,21 @@ export function CliproxyPage() {
))} ))}
</div> </div>
)} )}
</CardContent>
</Card>
</div> </div>
{/* Custom Variants */} {/* Custom Variants */}
<div className="space-y-4">
<div className="flex items-center justify-between">
<div> <div>
<h2 className="text-lg font-semibold mb-3">Custom Variants</h2> <h2 className="text-lg font-semibold tracking-tight">Custom Variants</h2>
<p className="text-sm text-muted-foreground">
Create custom aliases for providers with specific accounts.
</p>
</div>
</div>
{isLoading ? ( {isLoading ? (
<div className="text-muted-foreground">Loading variants...</div> <div className="text-muted-foreground">Loading variants...</div>
) : ( ) : (