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 Icon from 'Components/Icon';
import Link from 'Components/Link/Link';
import { icons } from 'Helpers/Props';
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 getDetailedList(statusMessages) {
return (
{
statusMessages.map(({ title, messages }) => {
return (
{title}
{
messages.map((message) => {
return (
{message}
);
})
}
);
})
}
);
}
function formatMissing(value) {
if (value === undefined || value === 0 || value === '0') {
return ( );
}
return value;
}
function formatChange(oldValue, newValue) {
return (
{formatMissing(oldValue)} {formatMissing(newValue)}
);
}
function HistoryDetails(props) {
const {
eventType,
sourceTitle,
data,
downloadId,
shortDateFormat,
timeFormat
} = props;
if (eventType === 'grabbed') {
const {
indexer,
releaseGroup,
customFormatScore,
nzbInfoUrl,
downloadClient,
downloadClientName,
age,
ageHours,
ageMinutes,
publishedDate
} = data;
const downloadClientNameInfo = downloadClientName ?? downloadClient;
return (
{
indexer ?
:
null
}
{
releaseGroup ?
:
null
}
{
customFormatScore && customFormatScore !== '0' ?
:
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 === 'trackFileImported') {
const {
customFormatScore,
droppedPath,
importedPath
} = data;
return (
{
droppedPath ?
:
null
}
{
importedPath ?
:
null
}
{
customFormatScore && customFormatScore !== '0' ?
:
null
}
);
}
if (eventType === 'trackFileDeleted') {
const {
reason,
customFormatScore
} = data;
let reasonMessage = '';
switch (reason) {
case 'Manual':
reasonMessage = 'File was deleted by via UI';
break;
case 'MissingFromDisk':
reasonMessage = 'Lidarr was unable to find the file on disk so the file was unlinked from the album/track in the database';
break;
case 'Upgrade':
reasonMessage = 'File was deleted to import an upgrade';
break;
default:
reasonMessage = '';
}
return (
{
customFormatScore && customFormatScore !== '0' ?
:
null
}
);
}
if (eventType === 'trackFileRenamed') {
const {
sourcePath,
path
} = data;
return (
);
}
if (eventType === 'trackFileRetagged') {
const {
diff,
tagsScrubbed
} = data;
return (
{
JSON.parse(diff).map(({ field, oldValue, newValue }) => {
return (
);
})
}
: }
/>
);
}
if (eventType === 'albumImportIncomplete') {
const {
statusMessages
} = data;
return (
{
!!statusMessages &&
}
);
}
if (eventType === 'downloadImported') {
const {
indexer,
releaseGroup,
customFormatScore,
nzbInfoUrl,
downloadClient,
age,
ageHours,
ageMinutes,
publishedDate
} = data;
return (
{
indexer ?
:
null
}
{
releaseGroup ?
:
null
}
{
customFormatScore && customFormatScore !== '0' ?
:
null
}
{
nzbInfoUrl ?
{translate('InfoUrl')}
{nzbInfoUrl}
:
null
}
{
downloadClient ?
:
null
}
{
downloadId ?
:
null
}
{
age || ageHours || ageMinutes ?
:
null
}
{
publishedDate ?
:
null
}
);
}
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;