All files / pages AdminJobsPage.js

100% Statements 10/10
100% Branches 0/0
100% Functions 4/4
100% Lines 9/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                  1x       3x           3x         3x 1x 1x         3x             3x         3x                            
import React from "react";
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import PagedJobsTable from "main/components/Jobs/PagedJobsTable";
import Accordion from "react-bootstrap/Accordion";
import TestJobForm from "main/components/Jobs/TestJobForm";
import { toast } from "react-toastify";
 
import { useBackendMutation } from "main/utils/useBackend";
 
const AdminJobsPage = () => {
 
  // *** Test job ***
 
  const objectToAxiosParamsTestJob = (data) => ({
    url: `/api/jobs/launch/testjob?fail=${data.fail}&sleepMs=${data.sleepMs}`,
    method: "POST",
  });
 
  // Stryker disable all
  const testJobMutation = useBackendMutation(objectToAxiosParamsTestJob, {}, [
    "/api/jobs/all",
  ]);
  // Stryker restore all
 
  const submitTestJob = async (data) => {
    toast("Submitted job: Test Job");
    testJobMutation.mutate(data);
  };
 
  
 
const jobLaunchers = [
  {
    name: "Test Job",
    form: <TestJobForm submitAction={submitTestJob} />,
  },
];
 
return (
  <BasicLayout>
    <h2 className="p-3">Launch Jobs</h2>
    <Accordion>
      {jobLaunchers.map((jobLauncher, index) => (
        <Accordion.Item eventKey={index} key={index}>
          <Accordion.Header>{jobLauncher.name}</Accordion.Header>
          <Accordion.Body>{jobLauncher.form}</Accordion.Body>
        </Accordion.Item>
      ))}
    </Accordion>
 
    <h2 className="p-3">Job Status</h2>
    <PagedJobsTable />
  </BasicLayout>
);
};
 
export default AdminJobsPage;