import classNames from 'classnames'; import React from 'react'; import { HistoryEventRow } from './HistoryEventRow'; import { ManagedReader } from '../ManagedReader'; import type { IManagedResourceSummary } from '../../domain'; import { usePollingData } from '../../presentation/hooks/usePollingData.hook'; import type { IModalComponentProps } from '../../presentation/modal'; import { ModalBody, ModalHeader, showModal } from '../../presentation/modal'; import { standardGridTableLayout, Table } from '../../presentation/tables'; import { Spinner } from '../../widgets/spinners/Spinner'; import './ManagedResourceHistoryModal.less'; export type IManagedResourceHistoryModalProps = IModalComponentProps & Pick; const EVENT_POLLING_INTERVAL = 10 * 1000; export const showManagedResourceHistoryModal = (props: IManagedResourceHistoryModalProps) => showModal(ManagedResourceHistoryModal, props); const tableLayout = standardGridTableLayout([{ unit: 'px', size: 70 }, 8, 1.5]); export const ManagedResourceHistoryModal = ({ id, displayName, dismissModal }: IManagedResourceHistoryModalProps) => { const { status: historyEventStatus, result: historyEvents, refresh } = usePollingData( () => ManagedReader.getResourceHistory(id), null, EVENT_POLLING_INTERVAL, [], ); const isLoading = !historyEvents && ['NONE', 'PENDING'].includes(historyEventStatus); const shouldShowExistingData = !isLoading && historyEventStatus !== 'REJECTED'; return ( <> Resource history - {displayName}
{isLoading && } {historyEventStatus === 'REJECTED' && (
Something went wrong.
)} {shouldShowExistingData && (
delta || tasks || message || reason || exceptionMessage, )} > {(historyEvents || []).map((event) => ( ))}
)}
); };