Shell_Casing

run-tests

May 6th, 2021
478
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { useContext, useState } from 'react';
  2. import { useSelector, useDispatch } from "react-redux";
  3. import classes from './cases.module.css';
  4. import { alluxioCasesAction, eventsAction } from "../../../store/actions/autoActions";
  5. import { GlobalContext } from "../../../context/global";
  6.  
  7. export const RunTests = props => {
  8.  
  9.     const [clicked, setClicked] = useState(false);
  10.  
  11.     // store data
  12.     const { user_name } = useSelector(state => state.auth.userData); // user
  13.  
  14.     const dispatch = useDispatch();
  15.  
  16.     const { jira_id } = useContext(GlobalContext);
  17.  
  18.     const runAlluxioTests = async () => {
  19.         setClicked(true);
  20.         const values = { user: user_name, jira_id, action: 'runtests' };
  21.         await dispatch(alluxioCasesAction(values));
  22.         await dispatch(eventsAction(jira_id));
  23.     };
  24.  
  25.     return (
  26.  
  27.         <>
  28.             <label className={`${classes.label} mt-5 mb-2`}>
  29.                 <p className="text-gray-500">Run tests</p>
  30.             </label>
  31.             <button onClick={ runAlluxioTests }
  32.                     type={`button`}
  33.                     hidden={ clicked }
  34.                 Run tests
  35.             </button>
  36.         </>
  37.     );
  38.  
  39. };
RAW Paste Data