import PropTypes from 'prop-types';
import React from 'react';
import DescriptionList from 'Components/DescriptionList/DescriptionList';
import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem';
import DescriptionListItemDescription from 'Components/DescriptionList/DescriptionListItemDescription';
import DescriptionListItemTitle from 'Components/DescriptionList/DescriptionListItemTitle';
import Link from 'Components/Link/Link';
import formatDateTime from 'Utilities/Date/formatDateTime';
import formatAge from 'Utilities/Number/formatAge';
import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore';
import translate from 'Utilities/String/translate';
import styles from './HistoryDetails.css';
function HistoryDetails(props) {
const {
eventType,
sourceTitle,
data,
downloadId,
shortDateFormat,
timeFormat
} = props;
if (eventType === 'grabbed') {
const {
indexer,
releaseGroup,
seriesMatchType,
customFormatScore,
nzbInfoUrl,
downloadClient,
downloadClientName,
age,
ageHours,
ageMinutes,
publishedDate
} = data;
const downloadClientNameInfo = downloadClientName ?? downloadClient;
return (
{
indexer ?
:
null
}
{
releaseGroup ?
:
null
}
{
customFormatScore && customFormatScore !== '0' ?
:
null
}
{
seriesMatchType ?
:
null
}
{
nzbInfoUrl ?
{translate('InfoUrl')}
{nzbInfoUrl}
:
null
}
{
downloadClientNameInfo ?
:
null
}
{
downloadId ?
:
null
}
{
age || ageHours || ageMinutes ?
:
null
}
{
publishedDate ?
:
null
}
);
}
if (eventType === 'downloadFailed') {
const {
message
} = data;
return (
{
downloadId ?
:
null
}
{
message ?
:
null
}
);
}
if (eventType === 'downloadFolderImported') {
const {
customFormatScore,
droppedPath,
importedPath
} = data;
return (
{
droppedPath ?
:
null
}
{
importedPath ?
:
null
}
{
customFormatScore && customFormatScore !== '0' ?
:
null
}
);
}
if (eventType === 'episodeFileDeleted') {
const {
reason,
customFormatScore
} = data;
let reasonMessage = '';
switch (reason) {
case 'Manual':
reasonMessage = translate('DeletedReasonManual');
break;
case 'MissingFromDisk':
reasonMessage = translate('DeletedReasonEpisodeMissingFromDisk');
break;
case 'Upgrade':
reasonMessage = translate('DeletedReasonUpgrade');
break;
default:
reasonMessage = '';
}
return (
{
customFormatScore && customFormatScore !== '0' ?
:
null
}
);
}
if (eventType === 'episodeFileRenamed') {
const {
sourcePath,
sourceRelativePath,
path,
relativePath
} = data;
return (
);
}
if (eventType === 'downloadIgnored') {
const {
message
} = data;
return (
{
downloadId ?
:
null
}
{
message ?
:
null
}
);
}
return (
);
}
HistoryDetails.propTypes = {
eventType: PropTypes.string.isRequired,
sourceTitle: PropTypes.string.isRequired,
data: PropTypes.object.isRequired,
downloadId: PropTypes.string,
shortDateFormat: PropTypes.string.isRequired,
timeFormat: PropTypes.string.isRequired
};
export default HistoryDetails;