Skip to content

Commit 6c3578a

Browse files
committed
feat: enhance AnalyzeLogs component with AI provider configuration prompt
- Updated the AnalyzeLogs component to display a message and button for configuring AI providers when none are available, improving user guidance. - Added a link to the settings page for easy access to AI provider configuration. - Integrated new icon for the configuration button to enhance UI clarity. These changes improve the user experience by ensuring users are informed about the need to set up AI providers for log analysis.
1 parent b8db120 commit 6c3578a

1 file changed

Lines changed: 53 additions & 37 deletions

File tree

apps/dokploy/components/dashboard/docker/logs/analyze-logs.tsx

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
2-
import { Bot, Loader2, RotateCcw, X } from "lucide-react";
2+
import { Bot, Loader2, RotateCcw, Settings, X } from "lucide-react";
3+
import Link from "next/link";
34
import { useState } from "react";
45
import ReactMarkdown from "react-markdown";
56
import { toast } from "sonner";
@@ -91,42 +92,57 @@ export function AnalyzeLogs({ logs, context }: Props) {
9192
</div>
9293
<div className="p-4 space-y-3">
9394
{!data?.analysis ? (
94-
<>
95-
<Select value={aiId} onValueChange={setAiId}>
96-
<SelectTrigger className="h-9 text-sm">
97-
<SelectValue placeholder="Select AI provider..." />
98-
</SelectTrigger>
99-
<SelectContent>
100-
{providers?.map((p) => (
101-
<SelectItem key={p.aiId} value={p.aiId}>
102-
{p.name} ({p.model})
103-
</SelectItem>
104-
))}
105-
</SelectContent>
106-
</Select>
107-
<Button
108-
size="sm"
109-
className="w-full"
110-
disabled={!aiId || isPending || logs.length === 0}
111-
onClick={handleAnalyze}
112-
>
113-
{isPending ? (
114-
<>
115-
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" />
116-
Analyzing...
117-
</>
118-
) : (
119-
<>
120-
<Bot className="mr-2 h-3.5 w-3.5" />
121-
Analyze{" "}
122-
{logs.length > MAX_LOG_LINES
123-
? `last ${MAX_LOG_LINES}`
124-
: logs.length}{" "}
125-
lines
126-
</>
127-
)}
128-
</Button>
129-
</>
95+
providers && providers.length === 0 ? (
96+
<div className="flex flex-col items-center gap-3 py-2 text-center">
97+
<p className="text-sm text-muted-foreground">
98+
No AI providers configured. Set up a provider to start
99+
analyzing logs.
100+
</p>
101+
<Button size="sm" variant="outline" asChild>
102+
<Link href="/dashboard/settings/ai">
103+
<Settings className="mr-2 h-3.5 w-3.5" />
104+
Configure AI Provider
105+
</Link>
106+
</Button>
107+
</div>
108+
) : (
109+
<>
110+
<Select value={aiId} onValueChange={setAiId}>
111+
<SelectTrigger className="h-9 text-sm">
112+
<SelectValue placeholder="Select AI provider..." />
113+
</SelectTrigger>
114+
<SelectContent>
115+
{providers?.map((p) => (
116+
<SelectItem key={p.aiId} value={p.aiId}>
117+
{p.name} ({p.model})
118+
</SelectItem>
119+
))}
120+
</SelectContent>
121+
</Select>
122+
<Button
123+
size="sm"
124+
className="w-full"
125+
disabled={!aiId || isPending || logs.length === 0}
126+
onClick={handleAnalyze}
127+
>
128+
{isPending ? (
129+
<>
130+
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" />
131+
Analyzing...
132+
</>
133+
) : (
134+
<>
135+
<Bot className="mr-2 h-3.5 w-3.5" />
136+
Analyze{" "}
137+
{logs.length > MAX_LOG_LINES
138+
? `last ${MAX_LOG_LINES}`
139+
: logs.length}{" "}
140+
lines
141+
</>
142+
)}
143+
</Button>
144+
</>
145+
)
130146
) : (
131147
<>
132148
<div className="max-h-[400px] overflow-y-auto">

0 commit comments

Comments
 (0)