All files / src/pages/flowsheet-page/flowsheet/PropertiesSidebar/MachineLearning CancelPanel.tsx

75% Statements 9/12
33.33% Branches 10/30
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                  75x 75x   75x     75x       6x 75x                                                                     450x 81x      
import { BrainCircuit, RefreshCcw } from "lucide-react";
import { Button } from "@/ahuora-design-system/ui/button";
import { MlModelRead } from "@/api/apiStore.gen";
 
interface CancelPanelProps {
  model: MlModelRead;
  onCancel: () => void;
}
 
export default function CancelPanel(props: CancelPanelProps) {
  const isVisible = props.model.is_resetting || props.model.is_updating;
  const previousUploadSessionId =
    props.model.mapping_update_snapshot?.["csv_upload_session_id"];
 
  const isCancelBtnVisible =
    previousUploadSessionId == null ||
    props.model.csv_upload_session === previousUploadSessionId;
 
  return (
    <>
      {isVisible && (
        <div
          className={`w-full shrink-0 border-t-2 border- bg-card p-5 rounded-md ${!isCancelBtnVisible ? "pt-6" : ""}`}
        >
          <div className="flex flex-col gap-3 sm:flex-row sm:justify-between sm:items-center">
            <div className="flex flex-row items-center gap-3">
              {props.model.is_resetting && (
                <>
                  <BrainCircuit />
                  <p className="opacity-75">
                    Currently resetting model with new data...
                  </p>
                </>
              )}
              {props.model.is_updating && (
                <>
                  <RefreshCcw />
                  <p className="opacity-75">
                    Currently updating column mappings...
                  </p>
                </>
              )}
            </div>
 
            {isCancelBtnVisible && (
              <Button
                className="shrink-0"
                variant="destructive"
                onClick={props.onCancel}
              >
                Cancel
              </Button>
            )}
          </div>
        </div>
      )}
    </>
  );
}