diff --git a/src/pages/catalog.js b/src/pages/catalog.js index 9b12ae7f..dbe44ab6 100644 --- a/src/pages/catalog.js +++ b/src/pages/catalog.js @@ -1,12 +1,11 @@ import { Error, Link } from '@/components/' -import { CopyButton } from '@/components/copy-button' +import { License } from '@/components/dashboard' import { Layout } from '@/components/layout' -import { getDatasetName } from '@/lib/dataset-utils' import { - useFeedstock, useFeedstockDatasets, useFeedstocks, useMeta, + useRepo, } from '@/lib/endpoints' import { AddIcon, MinusIcon } from '@chakra-ui/icons' import { @@ -17,111 +16,187 @@ import { Box, Button, Container, - Flex, Heading, - List, - ListIcon, - ListItem, + SimpleGrid, Skeleton, + Table, + TableContainer, + Tbody, + Td, Text, + Th, + Thead, + Tr, + useColorModeValue, } from '@chakra-ui/react' -import { GoDatabase } from 'react-icons/go' -const DatasetListItem = ({ dataset }) => { - return ( - - - - - {dataset ? getDatasetName(dataset) : ''} - - - - ) -} - -const FeedstockRowAccordionItem = ({ feedstockId, feedstockSpec }) => { +const Feedstock = ({ id, spec, arrayIndex }) => { + const bgWeight = useColorModeValue(100, 500) const { datasets, datasetsError, isLoading: datasetsAreLoading, - } = useFeedstockDatasets(feedstockId) - const { meta, metaError, isLoading: metaIsLoading } = useMeta(feedstockSpec) + } = useFeedstockDatasets(id) + const { - fs: { spec = '', recipe_runs = [] } = {}, - fsError, - isLoading: fsIsLoading, - } = useFeedstock(feedstockId) + repo, + repoError, + isLoading: repoIsLoading, + } = useRepo(`https://api.github.com/repos/${spec}/commits/HEAD`) + + const { meta, metaError, isLoading: metaIsLoading } = useMeta(spec) - if (metaError || fsError || datasetsError) { + if (metaError || repoError || datasetsError) { return ( ) } + const placeholderImages = [ + 'https://images.unsplash.com/photo-1563974318767-a4de855d7b43?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2074&q=80', + 'https://images.unsplash.com/photo-1454789476662-53eb23ba5907?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=752&q=80', + 'https://images.unsplash.com/photo-1584267759777-8a74a4f72a91?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mjh8fG1ldGVvcm9sb2d5fGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60', + 'https://images.unsplash.com/photo-1513553404607-988bf2703777?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=736&q=80', + 'https://images.unsplash.com/photo-1583325958573-3c89e40551ad?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1471&q=80', + 'https://images.unsplash.com/photo-1580193813605-a5c78b4ee01a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=765&q=80', + ] + + const image = + meta?.image || placeholderImages[arrayIndex % placeholderImages.length] + + const colors = [ + 'red', + 'orange', + 'yellow', + 'green', + 'teal', + 'blue', + 'cyan', + 'purple', + 'pink', + ] + const color = colors[arrayIndex % colors.length] + return ( <> {' '} {datasets?.length > 0 ? ( - - {({ isExpanded }) => ( - <> - - - - {meta?.title} - - - {isExpanded ? ( - - ) : ( - - )} - - - - {meta?.description} - - - - {datasets?.map((dataset, index) => ( - - ))} - - - - - More Details - - - - > - )} - + + + + + + + + + + + {({ isExpanded }) => ( + <> + + + + + {meta?.title} + + + + + {isExpanded ? ( + + ) : ( + + )} + + + + + {meta?.description} + + + + + + + + + + + + + License: + + + + + + + + + Last Updated: + + + {repo?.commit.committer.date}{' '} + + + + + + Dataset Count: + + + {datasets?.length}{' '} + + + + + + + + > + )} + + + + + Browse Datasets + + + ) : ( <>> )} @@ -153,7 +228,12 @@ const Catalog = () => { - + {feedstocks ?.filter( (feedstock) => !feedstock.spec.includes('staged-recipes'), @@ -165,14 +245,15 @@ const Catalog = () => { .replace('-feedstock', '') .localeCompare(b.spec), ) - .map((feedstock) => ( - ( + + id={feedstock.id} + spec={feedstock.spec} + arrayIndex={index} + > ))} - +