All files / src/components/Playbooks/task/taskConfiguration/bulkTasks BulkTaskSelector.tsx

0% Statements 0/13
0% Branches 0/4
0% Functions 0/2
0% Lines 0/13

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                                                                           
import useCurrentTask from "../../../../../hooks/playbooks/task/useCurrentTask";
import useIsPrefetched from "../../../../../hooks/playbooks/useIsPrefetched";
import { updateCardById } from "../../../../../utils/execution/updateCardById";
import Checkbox from "../../../../common/Checkbox";
import ExecutionVarFieldSelection from "./ExecutionVarFieldSelection";
 
const key = "is_bulk_execution";
 
type BulkTaskSelectorProps = {
  id: string;
};
 
function BulkTaskSelector({ id }: BulkTaskSelectorProps) {
  const [task] = useCurrentTask(id);
  const isChecked = task?.execution_configuration?.[key];
  const isPrefetched = useIsPrefetched();
 
  const handleChange = () => {
    updateCardById(`execution_configuration.${key}`, !isChecked, id);
  };
 
  return (
    <div>
      <Checkbox
        id="is_bulk_execution"
        isChecked={isChecked ?? false}
        label="Run multiple times"
        onChange={handleChange}
        isSmall={true}
        disabled={!!isPrefetched}
      />
      {isChecked && <ExecutionVarFieldSelection id={id} />}
    </div>
  );
}
 
export default BulkTaskSelector;