Skip to content

Commit ba0e405

Browse files
authored
feat(card): create server card (#71)
* refactor: mock server * leftover * fix: review comments * leftover
1 parent 9442bec commit ba0e405

File tree

3 files changed

+269
-20
lines changed

3 files changed

+269
-20
lines changed

src/components/server-card.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ describe("ServerCard", () => {
1414
},
1515
};
1616

17-
it("renders server information with name, author and description", () => {
18-
render(<ServerCard server={mockServer} url="/servers/test-server" />);
17+
it("display server information with name, author and description", () => {
18+
render(<ServerCard server={mockServer} serverUrl="/servers/test-server" />);
1919

2020
expect(screen.getByText("test-org/test-server")).toBeTruthy();
2121
expect(screen.getByText("test-org")).toBeTruthy();
2222
expect(screen.getByText("This is a test server for MCP")).toBeTruthy();
2323
});
2424

25-
it("does not render author when repository data is missing", () => {
25+
it("does not show author when repository data is missing", () => {
2626
const minimalServer: V0ServerJson = {
2727
name: undefined,
2828
description: undefined,
@@ -38,8 +38,8 @@ describe("ServerCard", () => {
3838
expect(screen.getByText("No description available")).toBeTruthy();
3939
});
4040

41-
it("renders copy URL button", () => {
42-
render(<ServerCard server={mockServer} url="/servers/test-server" />);
41+
it("has copy URL button", () => {
42+
render(<ServerCard server={mockServer} serverUrl="/servers/test-server" />);
4343

4444
const copyButton = screen.getByRole("button", { name: /copy url/i });
4545
expect(copyButton).toBeTruthy();

src/components/server-card.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,26 @@ import type { V0ServerJson } from "@/generated/types.gen";
1515

1616
interface ServerCardProps {
1717
server: V0ServerJson;
18-
/**
19-
* The MCP server URL
20-
*/
21-
url?: string;
18+
serverUrl?: string;
2219
}
2320

2421
/**
2522
* Server card component that displays MCP server information
26-
* from the catalog, following the Figma design specifications.
23+
* from the catalog
2724
*/
28-
export function ServerCard({ server, url }: ServerCardProps) {
25+
export function ServerCard({ server, serverUrl }: ServerCardProps) {
2926
const { name, description, repository, remotes } = server;
30-
const serverName = name;
3127
const author = repository?.id;
3228
const isVirtualMcp = remotes && remotes.length > 0;
3329

3430
const handleCopyUrl = async () => {
35-
if (!url) {
31+
if (!serverUrl) {
3632
toast.error("URL not available");
3733
return;
3834
}
3935

4036
try {
41-
await navigator.clipboard.writeText(url);
37+
await navigator.clipboard.writeText(serverUrl);
4238
toast.success("URL copied to clipboard");
4339
} catch {
4440
toast.error("Failed to copy URL");
@@ -49,10 +45,10 @@ export function ServerCard({ server, url }: ServerCardProps) {
4945
<Card className="flex h-full w-full flex-col shadow-none rounded-md">
5046
<CardHeader className="gap-2 pb-4">
5147
<CardTitle className="text-xl font-semibold leading-7 tracking-tight">
52-
{serverName}
48+
{name}
5349
</CardTitle>
5450
<CardDescription className="flex items-center gap-1.5 text-xs leading-5">
55-
<span>{author}</span>
51+
{author && <span>{author}</span>}
5652
{isVirtualMcp && (
5753
<Badge variant="secondary" className="text-xs">
5854
Virtual MCP

0 commit comments

Comments
 (0)