All files / src/pages/flowsheet-page/flowsheet/Canvas DefinedStatusButton.tsx

100% Statements 9/9
100% Branches 1/1
100% Functions 3/3
100% Lines 9/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                        4292x 4292x 4292x   4292x 9708x     4292x 1132x     3160x                     1x              
import { ListChecks, ListX } from "lucide-react";
import { StatusIndicator } from "../../../../ahuora-design-system/ui/ui-status-indicator";
import {
  useCurrentGroupId,
  useGroupGraphicsObjects,
} from "../../../../hooks/flowsheetObjects";
import { useSearchParam } from "../../../../hooks/searchParams";
import { ToolTipCover } from "../../../../ahuora-design-system/ui/tooltip";
import { Button } from "../../../../ahuora-design-system/ui/button";
import { ContentTypes } from "../LeftSideBar/LeftSideBarTabDefinitions";
 
export function DefinedStatusButton() {
  const groupId = useCurrentGroupId();
  const objects = useGroupGraphicsObjects(groupId);
  const [_, setContent] = useSearchParam("content");
 
  const hasUnderdefined = objects?.some(
    (object) => object.simulationObject.unspecifiedProperties.length > 0
  );
 
  if (!hasUnderdefined) {
    return null;
  }
 
  return (
    <ToolTipCover
      content="Not all objects are defined. Click to view details."
      delay={100}
      side="bottom"
    >
      <Button
        aria-label="View underdefined objects"
        className="h-full px-2"
        variant="outline"
        onClick={() => {
          setContent(ContentTypes.objectList);
        }}
      >
        <StatusIndicator variant="error" />
      </Button>
    </ToolTipCover>
  );
}