All files / src/components/AddCondition BashCommandOutput.tsx

0% Statements 0/18
100% Branches 0/0
0% Functions 0/3
0% Lines 0/18

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                                                                                           
import React from "react";
import { useSelector } from "react-redux";
import { additionalStateSelector } from "../../store/features/drawers/drawersSlice.ts";
import useEdgeConditions from "../../hooks/playbooks/useEdgeConditions.ts";
import { bashCommandOutputOptions } from "../../utils/conditionals/typeOptions/index.ts";
import HandleTypes from "./HandleTypes.tsx";
import CustomInput from "../Inputs/CustomInput.tsx";
import { InputTypes } from "../../types/inputs/inputTypes.ts";
import useIsPrefetched from "../../hooks/playbooks/useIsPrefetched.ts";
import { RuleType } from "../common/Conditions/types/RuleTypes.ts";
 
function BashCommandOutput({ rule, condition, conditionIndex }) {
  const { id } = useSelector(additionalStateSelector);
  const { handleRule } = useEdgeConditions(id);
  const keyValue = condition?.type?.toLowerCase();
  const isPrefetched = useIsPrefetched();
 
  const handleChange = (val: string | undefined, type: string) => {
    handleRule(type, val, conditionIndex, RuleType.RULE);
  };
 
  return (
    <>
      <div className="flex items-center gap-1">
        <CustomInput
          inputType={InputTypes.DROPDOWN}
          error={undefined}
          options={bashCommandOutputOptions}
          value={rule.type}
          placeholder={`Select Type`}
          handleChange={(id: string) => handleChange(id, `${keyValue}.type`)}
          disabled={!!isPrefetched}
        />
      </div>
 
      <HandleTypes
        condition={condition}
        rule={rule}
        conditionIndex={conditionIndex}
      />
    </>
  );
}
 
export default BashCommandOutput;