mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-31 17:35:30 +08:00
fix: design changes to plugins settings tab
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Trash2, RefreshCw, GitBranch, Loader2, ServerCrash, ChevronRight, ShieldAlert, ExternalLink, BookOpen } from 'lucide-react';
|
import { Trash2, RefreshCw, GitBranch, Loader2, ServerCrash, ChevronRight, ShieldAlert, ExternalLink, BookOpen, Download, BarChart3 } from 'lucide-react';
|
||||||
import { usePlugins } from '../../contexts/PluginsContext';
|
import { usePlugins } from '../../contexts/PluginsContext';
|
||||||
import PluginIcon from './PluginIcon';
|
import PluginIcon from './PluginIcon';
|
||||||
import type { Plugin } from '../../contexts/PluginsContext';
|
import type { Plugin } from '../../contexts/PluginsContext';
|
||||||
|
|
||||||
|
const STARTER_PLUGIN_URL = 'https://github.com/cloudcli-ai/cloudcli-plugin-starter';
|
||||||
|
|
||||||
/* ─── Toggle Switch ─────────────────────────────────────────────────────── */
|
/* ─── Toggle Switch ─────────────────────────────────────────────────────── */
|
||||||
function ToggleSwitch({ checked, onChange }: { checked: boolean; onChange: (v: boolean) => void }) {
|
function ToggleSwitch({ checked, onChange }: { checked: boolean; onChange: (v: boolean) => void }) {
|
||||||
return (
|
return (
|
||||||
@@ -186,6 +188,49 @@ function PluginCard({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ─── Starter Plugin Card ───────────────────────────────────────────────── */
|
||||||
|
function StarterPluginCard({ onInstall, installing }: { onInstall: () => void; installing: boolean }) {
|
||||||
|
return (
|
||||||
|
<div className="relative flex rounded-md border border-dashed border-border/60 bg-card/50 overflow-hidden opacity-65 hover:opacity-80 transition-opacity duration-200">
|
||||||
|
<div className="w-[3px] flex-shrink-0 bg-muted-foreground/10" />
|
||||||
|
<div className="flex-1 p-3.5 min-w-0">
|
||||||
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<div className="flex items-center gap-2.5 min-w-0">
|
||||||
|
<div className="flex-shrink-0 w-4 h-4 text-muted-foreground/60">
|
||||||
|
<BarChart3 className="w-4 h-4" />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
|
<span className="font-semibold text-sm text-foreground/70 leading-none">
|
||||||
|
Project Stats
|
||||||
|
</span>
|
||||||
|
<span className="font-mono text-[10px] text-muted-foreground/50 bg-muted/50 px-1.5 py-0.5 rounded">
|
||||||
|
starter
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground/60 mt-1 leading-snug">
|
||||||
|
File counts, lines of code, file-type breakdown, and recent activity for your project.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={onInstall}
|
||||||
|
disabled={installing}
|
||||||
|
className="flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-40 flex-shrink-0"
|
||||||
|
>
|
||||||
|
{installing ? (
|
||||||
|
<Loader2 className="w-3 h-3 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Download className="w-3 h-3" />
|
||||||
|
)}
|
||||||
|
{installing ? 'Installing…' : 'Install'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* ─── Empty State ───────────────────────────────────────────────────────── */
|
/* ─── Empty State ───────────────────────────────────────────────────────── */
|
||||||
function EmptyState() {
|
function EmptyState() {
|
||||||
return (
|
return (
|
||||||
@@ -212,6 +257,7 @@ export default function PluginSettingsTab() {
|
|||||||
|
|
||||||
const [gitUrl, setGitUrl] = useState('');
|
const [gitUrl, setGitUrl] = useState('');
|
||||||
const [installing, setInstalling] = useState(false);
|
const [installing, setInstalling] = useState(false);
|
||||||
|
const [installingStarter, setInstallingStarter] = useState(false);
|
||||||
const [installError, setInstallError] = useState<string | null>(null);
|
const [installError, setInstallError] = useState<string | null>(null);
|
||||||
const [confirmUninstall, setConfirmUninstall] = useState<string | null>(null);
|
const [confirmUninstall, setConfirmUninstall] = useState<string | null>(null);
|
||||||
const [updatingPlugin, setUpdatingPlugin] = useState<string | null>(null);
|
const [updatingPlugin, setUpdatingPlugin] = useState<string | null>(null);
|
||||||
@@ -240,6 +286,16 @@ export default function PluginSettingsTab() {
|
|||||||
setInstalling(false);
|
setInstalling(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleInstallStarter = async () => {
|
||||||
|
setInstallingStarter(true);
|
||||||
|
setInstallError(null);
|
||||||
|
const result = await installPlugin(STARTER_PLUGIN_URL);
|
||||||
|
if (!result.success) {
|
||||||
|
setInstallError(result.error || 'Installation failed');
|
||||||
|
}
|
||||||
|
setInstallingStarter(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleUninstall = async (name: string) => {
|
const handleUninstall = async (name: string) => {
|
||||||
if (confirmUninstall !== name) {
|
if (confirmUninstall !== name) {
|
||||||
setConfirmUninstall(name);
|
setConfirmUninstall(name);
|
||||||
@@ -249,6 +305,8 @@ export default function PluginSettingsTab() {
|
|||||||
setConfirmUninstall(null);
|
setConfirmUninstall(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasStarterInstalled = plugins.some((p) => p.name === 'project-stats');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -258,11 +316,14 @@ export default function PluginSettingsTab() {
|
|||||||
Plugins
|
Plugins
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
Extend the interface with custom tabs. Drop a folder in{' '}
|
Extend the interface with custom plugins. Install from{' '}
|
||||||
<code className="font-mono text-[10px] bg-muted px-1.5 py-0.5 rounded">
|
<code className="font-mono text-[10px] bg-muted px-1.5 py-0.5 rounded font-semibold">
|
||||||
~/.claude-code-ui/plugins/
|
git
|
||||||
</code>{' '}
|
</code>{' '}
|
||||||
or install from git.
|
or drop a folder in{' '}
|
||||||
|
<code className="font-mono text-[10px] bg-muted px-1.5 py-0.5 rounded font-semibold">
|
||||||
|
~/.claude-code-ui/plugins/
|
||||||
|
</code>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{!loading && plugins.length > 0 && (
|
{!loading && plugins.length > 0 && (
|
||||||
@@ -272,86 +333,47 @@ export default function PluginSettingsTab() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Install from Git */}
|
{/* Install from Git — compact */}
|
||||||
<div className="rounded-md border border-border bg-card p-3.5">
|
<div className="flex items-center gap-0 rounded-md border border-border bg-card overflow-hidden">
|
||||||
<div className="flex items-center gap-2 mb-3">
|
<span className="flex-shrink-0 pl-3 pr-1 text-muted-foreground/40">
|
||||||
<GitBranch className="w-3.5 h-3.5 text-muted-foreground/60" />
|
<GitBranch className="w-3 h-3" />
|
||||||
<span className="text-xs font-mono text-muted-foreground uppercase tracking-widest">
|
</span>
|
||||||
Install from git
|
<input
|
||||||
</span>
|
type="text"
|
||||||
</div>
|
value={gitUrl}
|
||||||
|
onChange={(e) => {
|
||||||
<div className="flex items-center gap-0 rounded-md border border-border bg-background focus-within:ring-1 focus-within:ring-ring overflow-hidden">
|
setGitUrl(e.target.value);
|
||||||
<span className="flex-shrink-0 pl-3 pr-1.5 font-mono text-xs text-muted-foreground/50 select-none">
|
setInstallError(null);
|
||||||
$
|
}}
|
||||||
</span>
|
placeholder="https://github.com/user/my-plugin"
|
||||||
<input
|
className="flex-1 px-2 py-2 text-xs font-mono bg-transparent text-foreground placeholder:text-muted-foreground/40 focus:outline-none"
|
||||||
type="text"
|
onKeyDown={(e) => {
|
||||||
value={gitUrl}
|
if (e.key === 'Enter') void handleInstall();
|
||||||
onChange={(e) => {
|
}}
|
||||||
setGitUrl(e.target.value);
|
/>
|
||||||
setInstallError(null);
|
<button
|
||||||
}}
|
onClick={handleInstall}
|
||||||
placeholder="git clone https://github.com/user/my-plugin"
|
disabled={installing || !gitUrl.trim()}
|
||||||
className="flex-1 px-1.5 py-2.5 text-xs font-mono bg-transparent text-foreground placeholder:text-muted-foreground/40 focus:outline-none"
|
className="flex-shrink-0 px-3.5 py-2 text-xs font-medium bg-foreground text-background hover:opacity-90 disabled:opacity-30 transition-opacity border-l border-border"
|
||||||
onKeyDown={(e) => {
|
>
|
||||||
if (e.key === 'Enter') void handleInstall();
|
{installing ? (
|
||||||
}}
|
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
||||||
/>
|
) : (
|
||||||
<button
|
'Install'
|
||||||
onClick={handleInstall}
|
)}
|
||||||
disabled={installing || !gitUrl.trim()}
|
</button>
|
||||||
className="flex-shrink-0 px-4 py-2.5 text-xs font-medium bg-foreground text-background hover:opacity-90 disabled:opacity-30 transition-opacity border-l border-border"
|
|
||||||
>
|
|
||||||
{installing ? (
|
|
||||||
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
|
||||||
) : (
|
|
||||||
'Install'
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{installError && (
|
|
||||||
<p className="mt-2 text-xs font-mono text-red-500">{installError}</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<p className="mt-2.5 flex items-start gap-1.5 text-[11px] text-muted-foreground/60 leading-snug">
|
|
||||||
<ShieldAlert className="w-3 h-3 mt-px flex-shrink-0" />
|
|
||||||
<span>
|
|
||||||
Plugins run with full access to the host page. Only install plugins
|
|
||||||
whose source code you have reviewed or from authors you trust.
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Build your own */}
|
{installError && (
|
||||||
<div className="flex items-center gap-4 rounded-md border border-dashed border-border/60 px-4 py-3">
|
<p className="text-xs font-mono text-red-500 -mt-3">{installError}</p>
|
||||||
<BookOpen className="w-4 h-4 text-muted-foreground/50 flex-shrink-0" />
|
)}
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="flex items-start gap-1.5 text-[11px] text-muted-foreground/50 leading-snug -mt-3">
|
||||||
Build your own plugin or start from an example.
|
<ShieldAlert className="w-3 h-3 mt-px flex-shrink-0" />
|
||||||
</p>
|
<span>
|
||||||
</div>
|
Only install plugins whose source code you have reviewed or from authors you trust.
|
||||||
<div className="flex items-center gap-3 flex-shrink-0">
|
</span>
|
||||||
<a
|
</p>
|
||||||
href="https://github.com/cloudcli-ai/cloudcli-plugin-starter"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
>
|
|
||||||
Starter plugin <ExternalLink className="w-3 h-3" />
|
|
||||||
</a>
|
|
||||||
<span className="text-border">|</span>
|
|
||||||
<a
|
|
||||||
href="https://cloudcli.ai/docs/plugin-overview"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
>
|
|
||||||
Docs <ExternalLink className="w-3 h-3" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Plugin List */}
|
{/* Plugin List */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -378,6 +400,40 @@ export default function PluginSettingsTab() {
|
|||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Starter plugin suggestion */}
|
||||||
|
{!loading && !hasStarterInstalled && (
|
||||||
|
<StarterPluginCard onInstall={handleInstallStarter} installing={installingStarter} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Build your own */}
|
||||||
|
<div className="flex items-center justify-between gap-4 pt-1">
|
||||||
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
|
<BookOpen className="w-3.5 h-3.5 text-muted-foreground/40 flex-shrink-0" />
|
||||||
|
<span className="text-[11px] text-muted-foreground/60">
|
||||||
|
Build your own plugin
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-3 flex-shrink-0">
|
||||||
|
<a
|
||||||
|
href="https://github.com/cloudcli-ai/cloudcli-plugin-starter"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex items-center gap-1 text-[11px] text-muted-foreground/60 hover:text-foreground transition-colors"
|
||||||
|
>
|
||||||
|
Starter <ExternalLink className="w-2.5 h-2.5" />
|
||||||
|
</a>
|
||||||
|
<span className="text-muted-foreground/20">·</span>
|
||||||
|
<a
|
||||||
|
href="https://cloudcli.ai/docs/plugin-overview"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex items-center gap-1 text-[11px] text-muted-foreground/60 hover:text-foreground transition-colors"
|
||||||
|
>
|
||||||
|
Docs <ExternalLink className="w-2.5 h-2.5" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user