import PropTypes from 'prop-types';
import React from 'react';
import formatAge from 'Utilities/Number/formatAge';
import formatDateTime from 'Utilities/Date/formatDateTime';
import formatPreferredWordScore from 'Utilities/Number/formatPreferredWordScore';
import Link from 'Components/Link/Link';
import DescriptionList from 'Components/DescriptionList/DescriptionList';
import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem';
import DescriptionListItemTitle from 'Components/DescriptionList/DescriptionListItemTitle';
import DescriptionListItemDescription from 'Components/DescriptionList/DescriptionListItemDescription';
import styles from './HistoryDetails.css';
function HistoryDetails(props) {
const {
eventType,
sourceTitle,
data,
shortDateFormat,
timeFormat
} = props;
if (eventType === 'grabbed') {
const {
indexer,
releaseGroup,
preferredWordScore,
nzbInfoUrl,
downloadClient,
downloadId,
age,
ageHours,
ageMinutes,
publishedDate
} = data;
return (
{
indexer ?
:
null
}
{
releaseGroup ?
:
null
}
{
preferredWordScore && preferredWordScore !== '0' ?
:
null
}
{
nzbInfoUrl ?
Info URL
{nzbInfoUrl}
:
null
}
{
downloadClient ?
:
null
}
{
downloadId ?
:
null
}
{
age || ageHours || ageMinutes ?
:
null
}
{
publishedDate ?
:
null
}
);
}
if (eventType === 'downloadFailed') {
const {
message
} = data;
return (
{
message ?
:
null
}
);
}
if (eventType === 'downloadFolderImported') {
const {
preferredWordScore,
droppedPath,
importedPath
} = data;
return (
{
droppedPath ?
:
null
}
{
importedPath ?
:
null
}
{
preferredWordScore && preferredWordScore !== '0' ?
:
null
}
);
}
if (eventType === 'episodeFileDeleted') {
const {
reason,
preferredWordScore
} = data;
let reasonMessage = '';
switch (reason) {
case 'Manual':
reasonMessage = 'File was deleted by via UI';
break;
case 'MissingFromDisk':
reasonMessage = 'Sonarr was unable to find the file on disk so it was removed';
break;
case 'Upgrade':
reasonMessage = 'File was deleted to import an upgrade';
break;
default:
reasonMessage = '';
}
return (
{
preferredWordScore && preferredWordScore !== '0' ?
:
null
}
);
}
if (eventType === 'episodeFileRenamed') {
const {
sourcePath,
sourceRelativePath,
path,
relativePath
} = data;
return (
);
}
if (eventType === 'downloadIgnored') {
const {
message
} = data;
return (
{
message ?
:
null
}
);
}
return (
);
}
HistoryDetails.propTypes = {
eventType: PropTypes.string.isRequired,
sourceTitle: PropTypes.string.isRequired,
data: PropTypes.object.isRequired,
shortDateFormat: PropTypes.string.isRequired,
timeFormat: PropTypes.string.isRequired
};
export default HistoryDetails;