All files / publisher/layouts/SnapsManagementLayout Tabs.tsx

100% Statements 6/6
50% Branches 1/2
100% Functions 3/3
100% Lines 4/4

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          25x 25x 150x             25x        
import { Link, resolvePath, useLocation } from "react-router-dom";
import { Tabs } from "@canonical/react-components";
import routes from "./routes";
 
function SnapsManagementLayout(): React.JSX.Element {
  const { pathname } = useLocation();
  const tabsRoutes = routes.find((r) => r.path === ":snapId")?.children ?? [];
  const tabsLinks = tabsRoutes.map(({ label, path }) => ({
    label,
    active: pathname.includes(`/${path}`),
    to: resolvePath(path, "./"),
    component: Link,
  }));
 
  return <Tabs listClassName="u-no-margin--bottom" links={tabsLinks} />;
}
 
export default SnapsManagementLayout;