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

68.75% Statements 11/16
46.15% Branches 6/13
100% Functions 1/1
88.88% Lines 8/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                      1179x 1179x 1179x   1179x         1179x         64x       696x       1811x      
import { FlowsheetTemplateTypeEnum } from "@/api/apiStore.gen";
import { useFlowsheet } from "@/hooks/project";
import { useSearchParam } from "../../hooks/searchParams";
import {
  FlowsheetWorkspace,
  ProjectPanelWorkspace,
} from "./flowsheet/FlowsheetWorkspace";
import { ContentTypes } from "./flowsheet/LeftSideBar/LeftSideBarTabDefinitions";
import { FlowsheetReadStateBoundary } from "./flowsheet/revisions/FlowsheetReadStateBoundary";
import { FlowsheetRevisionPreviewGate } from "./flowsheet/revisions/FlowsheetRevisionPreviewGate";
 
export default function FlowsheetPage() {
  const [tab] = useSearchParam("content", ContentTypes.unitOps);
  const flowsheet = useFlowsheet();
  const isTemplateFlowsheet =
    flowsheet?.flowsheet_template_type ===
      FlowsheetTemplateTypeEnum.PrivateTemplate ||
    flowsheet?.flowsheet_template_type ===
      FlowsheetTemplateTypeEnum.PublicTemplate;
  const activeTab =
    isTemplateFlowsheet && tab === ContentTypes.project
      ? ContentTypes.flowsheet
      : tab;
 
  if (activeTab === ContentTypes.project) {
    return <ProjectPanelWorkspace />;
  }
 
  return (
    <FlowsheetReadStateBoundary>
      <FlowsheetRevisionPreviewGate>
        <FlowsheetWorkspace activeTab={activeTab} />
      </FlowsheetRevisionPreviewGate>
    </FlowsheetReadStateBoundary>
  );
}