import React, { useContext } from 'react'; import { translate as __ } from 'foremanReact/common/I18n'; import { FormattedMessage } from 'react-intl'; import { Label } from '@patternfly/react-core'; import { TableComposable, TableVariant, Tbody, Td, Th, Thead, Tr, } from '@patternfly/react-table'; import WizardHeader from '../../../../components/WizardHeader'; import ActionSummary from '../ActionSummary'; import { BulkDeleteContext } from '../BulkDeleteContextWrapper'; import { getNumberOfEnvironments, getVersionListString, } from '../BulkDeleteHelpers'; export default () => { const { versions } = useContext(BulkDeleteContext); const affectedVersions = versions.filter(({ environments }) => !!environments.length); const pluralVersions = affectedVersions.length > 1; const versionList = getVersionListString(affectedVersions); const pluralEnvironments = getNumberOfEnvironments(versions) > 1; const columnHeaders = (() => { const columnList = [ __('Environment'), __('Hosts'), __('Activation keys'), ]; if (pluralVersions) columnList.push(__('Associated version')); return columnList; })(); return ( <> } /> {columnHeaders.map(col => {col})} {versions?.map(({ environments, version, }) => environments.map(({ id, name, activation_key_count: akCount, host_count: hostCount, }) => ( {name} {hostCount} {akCount} {pluralVersions && {`${__('Version')} ${version}`}} ))) } > ); };