mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-24 22:47:05 -04:00
(cherry picked from commit 05edd44ed6dfe73c25da021ef2600e609852f7e0) (cherry picked from commit ca372bee258523339aff2b868f8f9a619d44dbca) (cherry picked from commit 2a662afaef0bed9f8cd153d60eee5ecbe85508ba) Closes #10039 Closes #10045 Closes #10046
98 lines
2.7 KiB
JavaScript
98 lines
2.7 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import Icon from 'Components/Icon';
|
|
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
|
import Tooltip from 'Components/Tooltip/Tooltip';
|
|
import { icons, kinds, tooltipPositions } from 'Helpers/Props';
|
|
import formatTime from 'Utilities/Date/formatTime';
|
|
import formatTimeSpan from 'Utilities/Date/formatTimeSpan';
|
|
import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
|
import formatBytes from 'Utilities/Number/formatBytes';
|
|
import translate from 'Utilities/String/translate';
|
|
import styles from './TimeleftCell.css';
|
|
|
|
function TimeleftCell(props) {
|
|
const {
|
|
estimatedCompletionTime,
|
|
timeleft,
|
|
status,
|
|
size,
|
|
sizeleft,
|
|
showRelativeDates,
|
|
shortDateFormat,
|
|
timeFormat
|
|
} = props;
|
|
|
|
if (status === 'delay') {
|
|
const date = getRelativeDate({
|
|
date: estimatedCompletionTime,
|
|
shortDateFormat,
|
|
showRelativeDates
|
|
});
|
|
const time = formatTime(estimatedCompletionTime, timeFormat, { includeMinuteZero: true });
|
|
|
|
return (
|
|
<TableRowCell className={styles.timeleft}>
|
|
<Tooltip
|
|
anchor={<Icon name={icons.INFO} />}
|
|
tooltip={translate('DelayingDownloadUntil', { date, time })}
|
|
kind={kinds.INVERSE}
|
|
position={tooltipPositions.TOP}
|
|
/>
|
|
</TableRowCell>
|
|
);
|
|
}
|
|
|
|
if (status === 'downloadClientUnavailable') {
|
|
const date = getRelativeDate({
|
|
date: estimatedCompletionTime,
|
|
shortDateFormat,
|
|
showRelativeDates
|
|
});
|
|
const time = formatTime(estimatedCompletionTime, timeFormat, { includeMinuteZero: true });
|
|
|
|
return (
|
|
<TableRowCell className={styles.timeleft}>
|
|
<Tooltip
|
|
anchor={<Icon name={icons.INFO} />}
|
|
tooltip={translate('RetryingDownloadOn', { date, time })}
|
|
kind={kinds.INVERSE}
|
|
position={tooltipPositions.TOP}
|
|
/>
|
|
</TableRowCell>
|
|
);
|
|
}
|
|
|
|
if (!timeleft || status === 'completed' || status === 'failed') {
|
|
return (
|
|
<TableRowCell className={styles.timeleft}>
|
|
-
|
|
</TableRowCell>
|
|
);
|
|
}
|
|
|
|
const totalSize = formatBytes(size);
|
|
const remainingSize = formatBytes(sizeleft);
|
|
|
|
return (
|
|
<TableRowCell
|
|
className={styles.timeleft}
|
|
title={`${remainingSize} / ${totalSize}`}
|
|
>
|
|
{formatTimeSpan(timeleft)}
|
|
</TableRowCell>
|
|
);
|
|
}
|
|
|
|
TimeleftCell.propTypes = {
|
|
estimatedCompletionTime: PropTypes.string,
|
|
timeleft: PropTypes.string,
|
|
status: PropTypes.string.isRequired,
|
|
size: PropTypes.number.isRequired,
|
|
sizeleft: PropTypes.number.isRequired,
|
|
showRelativeDates: PropTypes.bool.isRequired,
|
|
shortDateFormat: PropTypes.string.isRequired,
|
|
timeFormat: PropTypes.string.isRequired
|
|
};
|
|
|
|
export default TimeleftCell;
|