import { UISref } from '@uirouter/react'; import React from 'react'; import { RelativeTimestamp } from '../RelativeTimestamp'; import type { IOrchestratedItem } from '../../domain'; import { robotToHuman, Tooltip } from '../../presentation'; import { LoadingAnimation } from '../../presentation/LoadingAnimation'; import { useDataWithRefresh } from '../../presentation/hooks/useDataWithRefresh.hook'; import { TaskReader } from '../../task'; import { TaskProgressBar } from '../../task/TaskProgressBar'; import { TOOLTIP_DELAY_SHOW } from '../utils/defaults'; interface IResourceTaskProps { id: string; name: string; } const DEFAULT_ICON_CLASSNAMES = 'far fa-hourglass md-icon-pending'; const getTaskStatusIconProps = (task?: IOrchestratedItem): string => { if (!task) return DEFAULT_ICON_CLASSNAMES; if (task.isCompleted) return 'fas fa-check md-icon-success'; if (task.isCanceled || task.isFailed) return 'fas fa-times md-icon-fail'; return DEFAULT_ICON_CLASSNAMES; }; export const ResourceTask = ({ id, name }: IResourceTaskProps) => { const { status, result } = useDataWithRefresh(() => TaskReader.getTask(id), undefined, [id]); if (status === 'PENDING' && !result) { return ; } const iconClassnames = getTaskStatusIconProps(result); const currentStage = result?.steps?.find((step) => step.isRunning); return (
  • {name} {result && !result.isCompleted && } {result && (
    {currentStage && !result.isCompleted && ( Current stage: {robotToHuman(currentStage.name)} ( ) )}
    )}
  • ); };