From 11ffca6bbd2a0bbe8c2bcaf19f04670102693de1 Mon Sep 17 00:00:00 2001 From: Blake Gentry Date: Wed, 15 May 2024 09:48:02 -0500 Subject: [PATCH] empty state for job list --- ui/src/components/JobList.tsx | 121 ++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 43 deletions(-) diff --git a/ui/src/components/JobList.tsx b/ui/src/components/JobList.tsx index 3e77434..f63f6ad 100644 --- a/ui/src/components/JobList.tsx +++ b/ui/src/components/JobList.tsx @@ -1,7 +1,8 @@ -import { useMemo } from "react"; +import React, { useMemo } from "react"; import { Link } from "@tanstack/react-router"; import { useTime } from "react-time-sync"; import { MagnifyingGlassIcon } from "@heroicons/react/20/solid"; +import { QueueListIcon } from "@heroicons/react/24/solid"; import { Job } from "@services/jobs"; import { JobState } from "@services/types"; @@ -126,25 +127,93 @@ const JobListItem = ({ job }: JobListItemProps) => ( ); -type JobListProps = { +type EmptySetIconProps = {} & React.ComponentProps<"svg">; + +const EmptySetIcon = (props: EmptySetIconProps) => ( + + + + +); + +const EmptyState = () => ( +
+ +

No jobs

+
+); + +type JobRowsProps = { canShowFewer: boolean; canShowMore: boolean; - loading?: boolean; jobs: Job[]; showFewer: () => void; showMore: () => void; - statesAndCounts: StatesAndCounts | undefined; }; -const JobList = ({ +const JobRows = ({ canShowFewer, canShowMore, jobs, - loading, showFewer, showMore, - statesAndCounts, -}: JobListProps) => { +}: JobRowsProps) => { + if (jobs.length === 0) { + return ; + } + return ( +
+
    + {jobs.map((job) => ( + + ))} +
+ +
+ ); +}; + +type JobListProps = { + canShowFewer: boolean; + canShowMore: boolean; + loading?: boolean; + jobs: Job[]; + showFewer: () => void; + showMore: () => void; + statesAndCounts: StatesAndCounts | undefined; +}; + +const JobList = (props: JobListProps) => { + const { loading, statesAndCounts } = props; + return (
@@ -170,41 +239,7 @@ const JobList = ({
- {loading ? ( -
Loading...
- ) : ( -
-
    - {jobs.map((job) => ( - - ))} -
- -
- )} + {loading ?
Loading...
: } ); };