All files / src/pages/workflows WorkflowExecutionLogs.tsx

0% Statements 0/20
0% Branches 0/10
0% Functions 0/3
0% Lines 0/20

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 61 62 63                                                                                                                             
/* eslint-disable react-hooks/exhaustive-deps */
import { useNavigate, useParams } from "react-router-dom";
import Heading from "../../components/Heading.js";
import SuspenseLoader from "../../components/Skeleton/SuspenseLoader.js";
import TableSkeleton from "../../components/Skeleton/TableLoader.js";
import { ChevronLeft } from "@mui/icons-material";
import { useGetWorkflowExecutionLogsQuery } from "../../store/features/workflow/api/getWorkflowExecutionLogsApi.ts";
import ExecutionsTable from "../../components/Playbooks/executions/ExecutionsTable.js";
import PaginatedTable from "../../components/PaginatedTable.tsx";
import usePaginationComponent from "../../hooks/common/usePaginationComponent.ts";
 
const WorkflowExecutionLogs = () => {
  const { workflow_run_id: workflowRunId } = useParams();
  const navigate = useNavigate();
  const { data, isFetching, refetch } = useGetWorkflowExecutionLogsQuery({
    workflowRunId: workflowRunId ?? "",
  });
  usePaginationComponent(refetch);
 
  const playbooksList =
    data?.workflow_execution_logs?? [];
 
 
  const total = data?.meta?.total_count ?? 0;
 
  return (
    <div>
      <Heading heading={workflowRunId + " Executions"} />
      <main className="flex flex-col gap-4 p-2 pt-4">
        <div className="flex items-center justify-between">
          <button
            onClick={() => navigate(-1)}
            className="p-1 text-sm border border-violet-500 rounded text-violet-500 flex items-center cursor-pointer hover:text-white hover:bg-violet-500 transition-all">
            <ChevronLeft /> All Workflows
          </button>
        </div>
        <SuspenseLoader loading={isFetching} loader={<TableSkeleton />}>
          <PaginatedTable
          renderTable={ExecutionsTable}
          data={
            playbooksList?.map((e) => ({
              ...e.playbook_execution,
              finished_at: e.finished_at,
              scheduled_at: e.scheduled_at,
              created_at: e.created_at,
              created_by: e.created_by,
            })) ?? []
          }
          total={total}
          tableContainerStyles={
            playbooksList?.length
              ? {}
              : { maxHeight: "35vh", minHeight: "35vh" }
          }
          />
        </SuspenseLoader>
      </main>
    </div>
  );
};
 
export default WorkflowExecutionLogs;