Skip to content

Commit

Permalink
[OPIK-228] [UX improvements] Implement empty states on the project pa…
Browse files Browse the repository at this point in the history
…ge (#427)
  • Loading branch information
andriidudar authored Oct 18, 2024
1 parent 4ae9200 commit 2b7cbef
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 16 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from "react";
import { Book, GraduationCap } from "lucide-react";
import logFirstTraceImageUrl from "/images/log-first-trace.png";
import { Button } from "@/components/ui/button";
import { buildDocsUrl } from "@/lib/utils";
import { Link } from "@tanstack/react-router";
import useAppStore from "@/store/AppStore";

type NoTracesPageProps = {
name: string;
};

const NoTracesPage: React.FC<NoTracesPageProps> = ({ name }) => {
const workspaceName = useAppStore((state) => state.activeWorkspaceName);

return (
<div className="min-w-[340px] py-6">
<div className="pb-6">
<h1
data-testid="traces-page-title"
className="comet-title-l truncate break-words"
>
{name}
</h1>
</div>
<div className="flex flex-col items-center rounded-md border bg-white px-6 pb-6 pt-20">
<h2 className="comet-title-m">Log your first trace</h2>
<div className="comet-body-s max-w-[570px] px-4 pb-8 pt-4 text-center text-muted-slate">
Logging traces helps you understand the flow of your application and
identify specific points in your application that may be causing
issues.
</div>
<img
className="max-h-[400px] object-cover"
src={logFirstTraceImageUrl}
alt="image first trace"
/>
<div className="flex flex-wrap justify-center gap-2 pt-8">
<Button variant="secondary" asChild>
<a
href={buildDocsUrl("/tracing/log_traces")}
target="_blank"
rel="noreferrer"
>
<Book className="mr-2 size-4"></Book>
Read documentation
</a>
</Button>
<Link to="/$workspaceName/quickstart" params={{ workspaceName }}>
<Button>
<GraduationCap className="mr-2 size-4" />
Explore Quickstart guide
</Button>
</Link>
</div>
</div>
</div>
);
};

export default NoTracesPage;
22 changes: 6 additions & 16 deletions apps/opik-frontend/src/components/pages/TracesPage/TracesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import { generateSelectColumDef } from "@/components/shared/DataTable/utils";
import TracesActionsButton from "@/components/pages/TracesPage/TracesActionsButton";
import DataTableRowHeightSelector from "@/components/shared/DataTableRowHeightSelector/DataTableRowHeightSelector";
import DataTableNoData from "@/components/shared/DataTableNoData/DataTableNoData";
import NoTracesPage from "@/components/pages/TracesPage/NoTracesPage";
import { ROW_HEIGHT } from "@/types/shared";
import { convertColumnDataToColumn } from "@/lib/table";
import { buildDocsUrl } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import TooltipWrapper from "@/components/shared/TooltipWrapper/TooltipWrapper";
import useProjectById from "@/api/projects/useProjectById";
Expand Down Expand Up @@ -213,6 +213,10 @@ const TracesPage = () => {
return <Loader />;
}

if (noData && rows.length === 0) {
return <NoTracesPage name={name} />;
}

return (
<div className="pt-6">
<div className="mb-4 flex items-center justify-between">
Expand Down Expand Up @@ -290,21 +294,7 @@ const TracesPage = () => {
rowSelection={rowSelection}
setRowSelection={setRowSelection}
rowHeight={height as ROW_HEIGHT}
noData={
<DataTableNoData title={noDataText}>
{noData && (
<Button variant="link">
<a
href={buildDocsUrl("/tracing/log_traces")}
target="_blank"
rel="noreferrer"
>
Check our documentation
</a>
</Button>
)}
</DataTableNoData>
}
noData={<DataTableNoData title={noDataText} />}
/>
<div className="py-4">
<DataTablePagination
Expand Down

0 comments on commit 2b7cbef

Please sign in to comment.