Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/api/search.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { api } from "./client";

export type SearchEntityType =
"servers" | "gateways" | "tools" | "resources" | "prompts" | "agents" | "teams" | "users";
| "servers"
| "gateways"
| "tools"
| "resources"
| "prompts"
| "agents"
| "teams"
| "users"
| "catalog";

export interface GlobalSearchItem {
id?: string;
Expand Down
71 changes: 70 additions & 1 deletion src/components/layout/HeaderQuickNav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,16 @@ describe("HeaderQuickNav", () => {
expect(searchEntities).toHaveBeenCalledWith(
expect.objectContaining({
query: "server",
entityTypes: ["servers", "gateways", "tools", "resources", "prompts", "agents", "teams"],
entityTypes: [
"servers",
"gateways",
"tools",
"resources",
"prompts",
"agents",
"teams",
"catalog",
],
limitPerType: 8,
teamId: null,
}),
Expand Down Expand Up @@ -392,6 +401,66 @@ describe("HeaderQuickNav", () => {
expect(mockNavigate).toHaveBeenCalledWith("/app/tools?selected=tool-1&search=tool");
});

it("groups catalog results under the server catalog label", async () => {
vi.mocked(searchEntities).mockResolvedValue({
query: "cloudflare",
entity_types: ["catalog"],
limit_per_type: 8,
results: {},
groups: [
{
entity_type: "catalog",
count: 1,
items: [
{ id: "cloudflare-docs", name: "Cloudflare Docs", description: "Cloudflare docs MCP" },
],
},
],
items: [],
count: 1,
});

renderQuickNav();

const input = screen.getByRole("searchbox", { name: "Search" });
fireEvent.focus(input);
fireEvent.change(input, { target: { value: "cloudflare" } });

expect(await screen.findByText("Server catalog")).toBeInTheDocument();
expect(screen.getByText("Cloudflare Docs")).toBeInTheDocument();
expect(screen.getByText("Cloudflare docs MCP")).toBeInTheDocument();
});

it("deep-links a selected catalog result into the catalog search", async () => {
const user = userEvent.setup();
vi.mocked(searchEntities).mockResolvedValue({
query: "cloudflare",
entity_types: ["catalog"],
limit_per_type: 8,
results: {},
groups: [
{
entity_type: "catalog",
count: 1,
items: [{ id: "cloudflare-docs", name: "Cloudflare Docs" }],
},
],
items: [],
count: 1,
});

renderQuickNav();

const input = screen.getByRole("searchbox", { name: "Search" });
fireEvent.focus(input);
fireEvent.change(input, { target: { value: "cloudflare" } });
await user.click(await screen.findByText("Cloudflare Docs"));

expect(mockNavigate).toHaveBeenCalledWith(
"/app/server-catalog?selected=cloudflare-docs&search=cloudflare",
);
});

it("navigates to the first result when the form is submitted", async () => {
vi.mocked(searchEntities).mockResolvedValue({
query: "resource",
Expand Down
3 changes: 3 additions & 0 deletions src/components/layout/HeaderQuickNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const BASE_SEARCH_ENTITY_TYPES: SearchEntityType[] = [
"prompts",
"agents",
"teams",
"catalog",
];

const ENTITY_ROUTE: Record<SearchEntityType, string> = {
Expand All @@ -36,6 +37,7 @@ const ENTITY_ROUTE: Record<SearchEntityType, string> = {
agents: "/app/agents",
teams: "/app/settings/teams",
users: "/app/settings/users",
catalog: "/app/server-catalog",
};

const ENTITY_LABEL_KEY: Record<SearchEntityType, string> = {
Expand All @@ -47,6 +49,7 @@ const ENTITY_LABEL_KEY: Record<SearchEntityType, string> = {
agents: "navigation.agents",
teams: "navigation.teams",
users: "navigation.users",
catalog: "navigation.serverCatalog",
};

type SearchStatus = "idle" | "loading" | "success" | "error";
Expand Down
Loading