All files / src/views/Package DependenciesList.tsx

0% Statements 0/9
0% Branches 0/6
0% Functions 0/2
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                                                 
import { Center, Stack } from "@chakra-ui/react";
import type { FunctionComponent } from "react";
import { usePackageState } from "./PackageState";
import testIds from "./testIds";
import { sanitizeVersion } from "../../api/package/util";
import { NavLink } from "../../components/NavLink";
import { PageLoader } from "../../components/PageLoader";
import { getPackagePath } from "../../util/url";
 
export const DependenciesList: FunctionComponent = () => {
  const assembly = usePackageState().assembly.data;
 
  if (!assembly) {
    return <PageLoader />;
  }
 
  const depEntries = Object.entries(assembly.dependencies ?? {});
 
  if (!depEntries.length) {
    return (
      <Center>This library does not have any known CDK dependencies</Center>
    );
  }
 
  return (
    <Stack
      data-testid={testIds.dependenciesList}
      direction="row"
      justify="center"
      mx="auto"
      spacing={4}
      wrap="wrap"
    >
      {depEntries.map(([name, version]) => (
        <NavLink
          _first={{ ml: 4 }}
          data-testid={testIds.dependenciesLink}
          fontWeight="semibold"
          key={`${name}-${version}`}
          p={2}
          to={getPackagePath({ name, version: sanitizeVersion(version) })}
        >
          {name} - {version}
        </NavLink>
      ))}
    </Stack>
  );
};