Skip to content

Commit 7e8b981

Browse files
committed
remove button concern from empty state component
1 parent 7a5ee1b commit 7e8b981

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

src/app/catalog/components/empty-state.tsx

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,35 @@
1+
import type { ReactNode } from "react";
12
import { IllustrationEmptyInbox } from "@/components/illustrations/illustration-empty-inbox";
23
import { IllustrationNoSearchResults } from "@/components/illustrations/illustration-no-search-results";
3-
import { Button } from "@/components/ui/button";
44

5-
interface NoServersEmptyStateProps {
6-
variant: "no-servers";
5+
interface EmptyStateProps {
6+
variant: "no-servers" | "no-results";
7+
title: string;
8+
description: string;
9+
actions?: ReactNode;
710
}
811

9-
interface NoResultsEmptyStateProps {
10-
variant: "no-results";
11-
searchQuery: string;
12-
onClearSearch: () => void;
13-
}
14-
15-
type EmptyStateProps = NoServersEmptyStateProps | NoResultsEmptyStateProps;
16-
17-
export function EmptyState(props: EmptyStateProps) {
18-
const isNoResults = props.variant === "no-results";
19-
12+
export function EmptyState({
13+
variant,
14+
title,
15+
description,
16+
actions,
17+
}: EmptyStateProps) {
2018
return (
2119
<div className="flex items-center justify-center py-20">
2220
<div className="flex flex-col items-center text-center gap-4 max-w-md">
23-
{isNoResults ? (
21+
{variant === "no-results" ? (
2422
<IllustrationNoSearchResults className="size-32" />
2523
) : (
2624
<IllustrationEmptyInbox className="size-32" />
2725
)}
2826

2927
<div className="space-y-2">
30-
<h2 className="text-xl font-semibold tracking-tight">
31-
{isNoResults ? "No results found" : "No servers available"}
32-
</h2>
33-
<p className="text-muted-foreground">
34-
{isNoResults
35-
? `We couldn't find any servers matching "${props.searchQuery}". Try adjusting your search.`
36-
: "There are no MCP servers in the catalog yet. Check back later."}
37-
</p>
28+
<h2 className="text-xl font-semibold tracking-tight">{title}</h2>
29+
<p className="text-muted-foreground">{description}</p>
3830
</div>
3931

40-
{isNoResults && (
41-
<div className="flex gap-2 mt-2">
42-
<Button variant="outline" onClick={props.onClearSearch}>
43-
Clear search
44-
</Button>
45-
</div>
46-
)}
32+
{actions}
4733
</div>
4834
</div>
4935
);

src/app/catalog/components/servers.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useRouter } from "next/navigation";
44
import { useMemo } from "react";
5+
import { Button } from "@/components/ui/button";
56
import type { V0ServerJson } from "@/generated/types.gen";
67
import { EmptyState } from "./empty-state";
78
import { ServerCard } from "./server-card";
@@ -52,12 +53,23 @@ export function Servers({
5253
return (
5354
<EmptyState
5455
variant="no-results"
55-
searchQuery={searchQuery}
56-
onClearSearch={onClearSearch}
56+
title="No results found"
57+
description={`We couldn't find any servers matching "${searchQuery}". Try adjusting your search.`}
58+
actions={
59+
<Button variant="outline" onClick={onClearSearch}>
60+
Clear search
61+
</Button>
62+
}
5763
/>
5864
);
5965
}
60-
return <EmptyState variant="no-servers" />;
66+
return (
67+
<EmptyState
68+
variant="no-servers"
69+
title="No servers available"
70+
description="There are no MCP servers in the catalog yet. Check back later."
71+
/>
72+
);
6173
}
6274

6375
if (viewMode === "list") {

0 commit comments

Comments
 (0)