Skip to content

feat: implement breadcrumbs according to design #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 20, 2025
10 changes: 0 additions & 10 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,4 @@ describe("App", () => {
).toBeVisible(),
);
});

it("should render breadcrumb", async () => {
render(<App />);
await waitFor(() =>
expect(
screen.getByRole("link", { name: "CodeGate Dashboard" }),
).toBeVisible(),
);
expect(screen.getByRole("link", { name: "Dashboard" })).toBeVisible();
});
});
33 changes: 2 additions & 31 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { Header } from "./components/Header";
import { PromptList } from "./components/PromptList";
import { Routes, Route, Link } from "react-router-dom";
import { Routes, Route } from "react-router-dom";
import { usePromptsData } from "./hooks/usePromptsData";
import { Sidebar } from "./components/Sidebar";
import { useSse } from "./hooks/useSse";
import {
Breadcrumb,
BreadcrumbList,
BreadcrumbItem,
BreadcrumbSeparator,
BreadcrumbPage,
} from "./components/ui/breadcrumb";
import { useBreadcrumb } from "./hooks/useBreadcrumb";
import { RouteWorkspace } from "./routes/route-workspace";
import { RouteWorkspaces } from "./routes/route-workspaces";
import { RouteCertificates } from "./routes/route-certificates";
Expand All @@ -23,7 +15,6 @@ import { RouteCertificateSecurity } from "./routes/route-certificate-security";
function App() {
const { data: prompts, isLoading } = usePromptsData();
useSse();
const breadcrumb = useBreadcrumb();

return (
<div className="flex w-screen h-screen">
Expand All @@ -33,27 +24,7 @@ function App() {
<div className="flex-1 flex flex-col overflow-hidden">
<Header />

<div className="px-6 py-3">
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<Link to="/">Dashboard</Link>
</BreadcrumbItem>
{breadcrumb && (
<>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage className="w-96 truncate">
{breadcrumb}
</BreadcrumbPage>
</BreadcrumbItem>
</>
)}
</BreadcrumbList>
</Breadcrumb>
</div>

<div className="flex-1 overflow-y-auto p-6">
<div className="flex-1 overflow-y-auto p-6 flex flex-col gap-3">
<Routes>
<Route path="/" element={<RouteDashboard />} />
<Route path="/prompt/:id" element={<RouteChat />} />
Expand Down
5 changes: 5 additions & 0 deletions src/components/BreadcrumbHome.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Breadcrumb } from "@stacklok/ui-kit";

export function BreadcrumbHome() {
return <Breadcrumb href="/">Dashboard</Breadcrumb>;
}
114 changes: 0 additions & 114 deletions src/components/ui/breadcrumb.tsx

This file was deleted.

52 changes: 0 additions & 52 deletions src/hooks/__tests__/useBreadcrumb.test.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions src/hooks/useBreadcrumb.ts

This file was deleted.

19 changes: 19 additions & 0 deletions src/routes/__tests__/route-certificate-security.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { render } from "@/lib/test-utils";
import { screen, within } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { RouteCertificateSecurity } from "../route-certificate-security";

describe("Certificate security", () => {
it("has breadcrumbs", () => {
render(<RouteCertificateSecurity />);

const breadcrumbs = screen.getByRole("list", { name: "Breadcrumbs" });
expect(breadcrumbs).toBeVisible();
expect(
within(breadcrumbs).getByRole("link", { name: "Dashboard" }),
).toHaveAttribute("href", "/");
expect(
within(breadcrumbs).getByText(/certificate security/i),
).toBeVisible();
});
});
13 changes: 12 additions & 1 deletion src/routes/__tests__/route-certificates.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from "@/lib/test-utils";
import { screen } from "@testing-library/react";
import { screen, within } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import userEvent from "@testing-library/user-event";
import { RouteCertificates } from "../route-certificates";
Expand Down Expand Up @@ -27,6 +27,17 @@ describe("Certificates", () => {
expect(screen.getByText("Linux")).toBeVisible();
});

it("has breadcrumbs", () => {
render(<RouteCertificates />);

const breadcrumbs = screen.getByRole("list", { name: "Breadcrumbs" });
expect(breadcrumbs).toBeVisible();
expect(
within(breadcrumbs).getByRole("link", { name: "Dashboard" }),
).toHaveAttribute("href", "/");
expect(within(breadcrumbs).getByText(/certificates/i)).toBeVisible();
});

it("should render macOS certificate installation", async () => {
render(<RouteCertificates />);

Expand Down
14 changes: 10 additions & 4 deletions src/routes/__tests__/route-chat.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ vi.mock("@/hooks/usePromptsData", () => ({
}));

describe("Chat", () => {
it("should render secret issue chat", () => {
it("render secret issue chat", () => {
render(<RouteChat />, {
routeConfig: {
initialEntries: ["/prompt/chatcmpl-7d87679de7ed41639eb91d8ebbaa6f72"],
Expand All @@ -60,9 +60,6 @@ describe("Chat", () => {
expect(screen.getByText(/REDACTED</i)).toBeVisible();
expect(screen.getByTestId("avatar-user")).toBeVisible();
expect(screen.getByTestId("avatar-ai")).toBeVisible();
expect(
screen.getByText(/do you see any security issue\?\./i),
).toBeVisible();
expect(
screen.getByRole("heading", {
name: /recommendations for security improvements/i,
Expand All @@ -76,5 +73,14 @@ describe("Chat", () => {
.getByRole("code")
.className.includes("language-tsx"),
).toBeTruthy();

const breadcrumbs = screen.getByRole("list", { name: "Breadcrumbs" });
expect(breadcrumbs).toBeVisible();
expect(
within(breadcrumbs).getByRole("link", { name: "Dashboard" }),
).toHaveAttribute("href", "/");
expect(
within(breadcrumbs).getByText(/do you see any security issue/i),
).toBeVisible();
});
});
21 changes: 21 additions & 0 deletions src/routes/__tests__/route-help.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { render } from "@/lib/test-utils";
import { screen, within } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { RouteHelp } from "../route-help";

describe("Help page", () => {
it("has breadcrumbs", () => {
render(<RouteHelp />, {
routeConfig: {
initialEntries: ["/help/continue-setup"],
},
pathConfig: "/help/:id",
});
const breadcrumbs = screen.getByRole("list", { name: "Breadcrumbs" });
expect(breadcrumbs).toBeVisible();
expect(
within(breadcrumbs).getByRole("link", { name: "Dashboard" }),
).toHaveAttribute("href", "/");
expect(within(breadcrumbs).getByText(/help/i)).toBeVisible();
});
});
Loading
Loading