From c81a03d34df2a68827e2f05df6a54336030b250e Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Wed, 8 Nov 2023 21:39:43 +0000 Subject: [PATCH] wip --- .../src/repositories/list/RepoListItem.tsx | 15 +++-- .../src/repositories/list/RepositoryList.tsx | 56 +++++++++++++++---- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/components/dashboard/src/repositories/list/RepoListItem.tsx b/components/dashboard/src/repositories/list/RepoListItem.tsx index 71daf711e02482..4c81df06a7ef50 100644 --- a/components/dashboard/src/repositories/list/RepoListItem.tsx +++ b/components/dashboard/src/repositories/list/RepoListItem.tsx @@ -19,17 +19,24 @@ export const RepositoryListItem: FC = ({ configuration }) => { const url = usePrettyRepoURL(configuration.cloneUrl); return ( -
  • -
    + + {configuration.name} + + {url} -
    + + + {configuration.creationTime + ?.toDate() + .toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })} +
    -
  • + ); }; diff --git a/components/dashboard/src/repositories/list/RepositoryList.tsx b/components/dashboard/src/repositories/list/RepositoryList.tsx index 11b3436c7b87b9..98a025448868fc 100644 --- a/components/dashboard/src/repositories/list/RepositoryList.tsx +++ b/components/dashboard/src/repositories/list/RepositoryList.tsx @@ -15,13 +15,23 @@ import { RepositoryListItem } from "./RepoListItem"; import { useListConfigurations } from "../../data/configurations/configuration-queries"; import { useStateWithDebounce } from "../../hooks/use-state-with-debounce"; import { TextInput } from "../../components/forms/TextInputField"; +import Pagination from "../../Pagination/Pagination"; const RepositoryListPage: FC = () => { const history = useHistory(); + + // TODO: Consider pushing this state into query params + const [currentPage, setCurrentPage] = useState(1); const [searchTerm, setSearchTerm, debouncedSearchTerm] = useStateWithDebounce(""); - const { data, isLoading } = useListConfigurations({ searchTerm: debouncedSearchTerm, page: 0, pageSize: 10 }); + + const pageSize = 10; + + const { data, isLoading } = useListConfigurations({ searchTerm: debouncedSearchTerm, page: currentPage, pageSize }); const [showCreateProjectModal, setShowCreateProjectModal] = useState(false); + // TODO: add this to response payload for pagination + const totalPages = data?.pagination?.total ?? 0 / pageSize; + const handleProjectCreated = useCallback( (project: Project) => { history.push(`/repositories/${project.id}`); @@ -31,25 +41,49 @@ const RepositoryListPage: FC = () => { return ( <> -
    -
    -
    - + {/* TODO: Consider updating Header to have an action button prop */} +
    +
    +
    -
    - + {/* Search/Filter bar */} +
    +
    + + {/* TODO: Add prebuild status filter dropdown */} +
    +
    {/* TODO: Add copy explaining what records we're showing & total records count */}
    {isLoading && } -
      - {!isLoading && - data?.configurations.map((configuration) => ( + + + + + + + + + + + {data?.configurations.map((configuration) => ( ))} - + +
      NameRepository URLCreatedPrebuilds
      + + {/* TODO: Refactor Pagination into podkit or to use podkit components internally */} +
    {showCreateProjectModal && (