Skip to content

Commit b1f142a

Browse files
authored
fixed Squished badge bug (kagent-dev#1011)
Fixed the squished badge bug with a ribbon as mentioned in kagent-dev#952 and made replace hardcoded Tailwind colors --------- Signed-off-by: Rutuj Dhawale <148652804+killjoycircuit@users.noreply.github.com>
1 parent 01760e3 commit b1f142a

1 file changed

Lines changed: 50 additions & 25 deletions

File tree

ui/src/components/AgentCard.tsx

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { DeleteButton } from "@/components/DeleteAgentButton";
55
import KagentLogo from "@/components/kagent-logo";
66
import Link from "next/link";
77
import { useRouter } from "next/navigation";
8-
import { Pencil } from "lucide-react";
8+
import { Pencil, AlertCircle, Clock } from "lucide-react";
99
import { k8sRefUtils } from "@/lib/k8sUtils";
10+
import { cn } from "@/lib/utils";
1011

1112
interface AgentCardProps {
1213
agentResponse: AgentResponse;
@@ -20,6 +21,7 @@ export function AgentCard({ agentResponse: { agent, model, modelProvider, deploy
2021
);
2122
const isBYO = agent.spec?.type === "BYO";
2223
const byoImage = isBYO ? agent.spec?.byo?.deployment?.image : undefined;
24+
const isReady = deploymentReady && accepted;
2325

2426
const handleEditClick = (e: React.MouseEvent) => {
2527
e.preventDefault();
@@ -28,23 +30,24 @@ export function AgentCard({ agentResponse: { agent, model, modelProvider, deploy
2830
};
2931

3032
const cardContent = (
31-
<Card className={`group transition-colors ${
32-
deploymentReady && accepted
33-
? 'cursor-pointer hover:border-violet-500'
34-
: 'border-gray-300'
35-
}`}>
36-
<CardHeader className="flex flex-row items-start justify-between space-y-0 pb-2">
33+
<Card className={cn(
34+
"group relative transition-all duration-200 overflow-hidden min-h-[200px]",
35+
isReady
36+
? 'cursor-pointer hover:border-primary hover:shadow-md'
37+
: 'cursor-default'
38+
)}>
39+
<CardHeader className="flex flex-row items-start justify-between space-y-0 pb-2 relative z-30">
3740
<CardTitle className="flex items-center gap-2 flex-1 min-w-0">
3841
<KagentLogo className="h-5 w-5 flex-shrink-0" />
3942
<span className="truncate">{agentRef}</span>
4043
</CardTitle>
41-
<div className="flex items-center space-x-2 flex-shrink-0 ml-2">
44+
<div className="flex items-center space-x-2 relative z-30 opacity-0 group-hover:opacity-100 transition-opacity">
4245
<Button
4346
variant="ghost"
4447
size="icon"
4548
onClick={handleEditClick}
4649
aria-label="Edit Agent"
47-
className="h-8 w-8"
50+
className="bg-background/80 hover:bg-background shadow-sm"
4851
>
4952
<Pencil className="h-4 w-4" />
5053
</Button>
@@ -54,33 +57,55 @@ export function AgentCard({ agentResponse: { agent, model, modelProvider, deploy
5457
/>
5558
</div>
5659
</CardHeader>
57-
<CardContent className="flex flex-col justify-between h-32 pt-2 relative">
58-
<p className="text-sm text-muted-foreground line-clamp-3 overflow-hidden flex-1">
60+
<CardContent className="flex flex-col justify-between h-32 relative z-10">
61+
<p className="text-sm text-muted-foreground line-clamp-3 overflow-hidden">
5962
{agent.spec.description}
6063
</p>
6164
<div className="mt-4 flex items-center text-xs text-muted-foreground">
6265
{isBYO ? (
63-
<span title={byoImage} className="truncate">
64-
Image: {byoImage}
65-
</span>
66+
<span title={byoImage} className="truncate">Image: {byoImage}</span>
6667
) : (
67-
<span className="truncate">
68-
{modelProvider} ({model})
69-
</span>
68+
<span className="truncate">{modelProvider} ({model})</span>
7069
)}
71-
72-
{/* this handles the ribbon part to edit it change the py to change height and bg-yellow-400/30 to change transparency levels*/}
7370
</div>
74-
{!deploymentReady && (
75-
<div className="absolute bottom-0 left-0 right-0 bg-yellow-400/30 text-yellow-900 text-xs px-3 py-1 rounded-b-lg flex justify-end items-center">
76-
<span className="font-bold whitespace-nowrap">Agent not Ready</span>
77-
</div>
78-
)}
7971
</CardContent>
72+
73+
{!isReady && (
74+
<div className={cn(
75+
"absolute inset-0 rounded-xl flex flex-col items-center justify-center z-20 backdrop-blur-[2px]",
76+
!accepted
77+
? "bg-destructive/90"
78+
: "bg-secondary/90"
79+
)}>
80+
<div className="text-center px-6 py-8 max-w-[80%]">
81+
<div className="flex justify-center mb-4">
82+
{!accepted ? (
83+
<AlertCircle className="h-12 w-12 text-destructive-foreground drop-shadow-lg" />
84+
) : (
85+
<Clock className="h-12 w-12 text-secondary-foreground drop-shadow-lg" />
86+
)}
87+
</div>
88+
<h3 className={cn(
89+
"font-bold text-2xl mb-3 drop-shadow-lg",
90+
!accepted ? "text-destructive-foreground" : "text-secondary-foreground"
91+
)}>
92+
{!accepted ? "Agent not Accepted" : "Agent not Ready"}
93+
</h3>
94+
<p className={cn(
95+
"text-base drop-shadow",
96+
!accepted ? "text-destructive-foreground/95" : "text-secondary-foreground/90"
97+
)}>
98+
{!accepted
99+
? "Configuration needs review"
100+
: "Still deploying..."}
101+
</p>
102+
</div>
103+
</div>
104+
)}
80105
</Card>
81106
);
82107

83-
return deploymentReady && accepted ? (
108+
return isReady ? (
84109
<Link href={`/agents/${agent.metadata.namespace}/${agent.metadata.name}/chat`} passHref>
85110
{cardContent}
86111
</Link>

0 commit comments

Comments
 (0)