import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { Tab, Tabs } from 'patternfly-react';
import { translate as __, sprintf } from 'foremanReact/common/I18n';
import { STATUS } from 'foremanReact/constants';
import MessageBox from 'foremanReact/components/common/MessageBox';
import Task from './Components/Task';
import RunningSteps from './Components/RunningSteps';
import Errors from './Components/Errors';
import Locks from './Components/Locks';
import Raw from './Components/Raw';
import { getTaskID } from './TasksDetailsHelper';
import { TaskSkeleton } from './Components/TaskSkeleton';
import './TaskDetails.scss';
const TaskDetails = ({
executionPlan,
failedSteps,
runningSteps,
locks,
links,
cancelStep,
taskReloadStart,
taskReloadStop,
APIerror,
...props
}) => {
const id = getTaskID();
const { taskReload, status, isLoading } = props;
useEffect(() => {
taskReloadStart(id);
return () => {
taskReloadStop();
};
}, [id, taskReloadStart, taskReloadStop]);
const taskProgressToggle = () => {
if (taskReload) {
taskReloadStop();
} else {
taskReloadStart(id);
}
};
if (status === STATUS.ERROR) {
return (