import PropTypes from 'prop-types';
import React from 'react';
import formatDateTime from 'Utilities/Date/formatDateTime';
import formatAge from 'Utilities/Number/formatAge';
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 { icons } from 'Helpers/Props';
import Icon from 'Components/Icon';
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,
shortDateFormat,
timeFormat
} = props;
if (eventType === 'grabbed') {
const {
indexer,
releaseGroup,
nzbInfoUrl,
downloadClient,
downloadId,
age,
ageHours,
ageMinutes,
publishedDate
} = data;
return (
{
!!indexer &&
}
{
!!releaseGroup &&
}
{
!!nzbInfoUrl &&
Info URL
{nzbInfoUrl}
}
{
!!downloadClient &&
}
{
!!downloadId &&
}
{
!!indexer &&
}
{
!!publishedDate &&
}
);
}
if (eventType === 'downloadFailed') {
const {
message
} = data;
return (
{
!!message &&
}
);
}
if (eventType === 'trackFileImported') {
const {
droppedPath,
importedPath
} = data;
return (
{
!!droppedPath &&
}
{
!!importedPath &&
}
);
}
if (eventType === 'trackFileDeleted') {
const {
reason
} = data;
let reasonMessage = '';
switch (reason) {
case 'Manual':
reasonMessage = 'File was deleted by via UI';
break;
case 'MissingFromDisk':
reasonMessage = 'Readarr 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 (
);
}
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,
nzbInfoUrl,
downloadClient,
downloadId,
age,
ageHours,
ageMinutes,
publishedDate
} = data;
return (
{
!!indexer &&
}
{
!!releaseGroup &&
}
{
!!nzbInfoUrl &&
Info URL
{nzbInfoUrl}
}
{
!!downloadClient &&
}
{
!!downloadId &&
}
{
!!indexer &&
}
{
!!publishedDate &&
}
);
}
if (eventType === 'downloadIgnored') {
const {
message
} = data;
return (
{
!!message &&
}
);
}
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;