All files / src/pages/flowsheet-page/flowsheet AddUnitOpButton.tsx

100% Statements 5/5
100% Branches 3/3
100% Functions 2/2
100% Lines 5/5

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              1846x   1846x 410x         1436x           12x                
import { Plus } from "lucide-react";
import { Button } from "../../../ahuora-design-system/ui/button";
import { useSearchParam } from "../../../hooks/searchParams";
import { ContentTypes } from "./LeftSideBar/LeftSideBarTabDefinitions";
import { ToolTipCover } from "../../../ahuora-design-system/ui/tooltip";
 
export default function AddUnitOpButton() {
  const [content, setContent] = useSearchParam("content");
 
  if (content == ContentTypes.unitOps || content == undefined) {
    return null; // We're already in the unit operations tab, no need to show the button.
  }
 
  // there is a schadcn bug for button sizing:
  //https://github.com/shadcn-ui/ui/issues/6316
  return (
    <ToolTipCover asChild content="Add Unit Operation" side="bottom">
      <Button
        className="mx-2"
        size="sm"
        aria-label="Show unit operation selection panel"
        onClick={() => setContent(ContentTypes.unitOps)}
      >
        <Plus />
        Unit Operations
      </Button>
    </ToolTipCover>
  );
}