2024-03-13 05:34:47 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { CommandBody } from 'Commands/Command';
|
|
|
|
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
|
|
|
import createMultiSeriesSelector from 'Store/Selectors/createMultiSeriesSelector';
|
|
|
|
import translate from 'Utilities/String/translate';
|
|
|
|
import styles from './QueuedTaskRowNameCell.css';
|
|
|
|
|
2024-04-25 19:59:00 +00:00
|
|
|
function formatTitles(titles: string[]) {
|
|
|
|
if (!titles) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (titles.length > 11) {
|
|
|
|
return (
|
|
|
|
<span title={titles.join(', ')}>
|
|
|
|
{titles.slice(0, 10).join(', ')}, {titles.length - 10} more
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <span>{titles.join(', ')}</span>;
|
|
|
|
}
|
|
|
|
|
2024-03-13 05:34:47 +00:00
|
|
|
export interface QueuedTaskRowNameCellProps {
|
|
|
|
commandName: string;
|
|
|
|
body: CommandBody;
|
|
|
|
clientUserAgent?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function QueuedTaskRowNameCell(
|
|
|
|
props: QueuedTaskRowNameCellProps
|
|
|
|
) {
|
|
|
|
const { commandName, body, clientUserAgent } = props;
|
|
|
|
const seriesIds = [...(body.seriesIds ?? [])];
|
|
|
|
|
|
|
|
if (body.seriesId) {
|
|
|
|
seriesIds.push(body.seriesId);
|
|
|
|
}
|
|
|
|
|
|
|
|
const series = useSelector(createMultiSeriesSelector(seriesIds));
|
2024-03-14 12:35:22 +00:00
|
|
|
const sortedSeries = series.sort((a, b) =>
|
|
|
|
a.sortTitle.localeCompare(b.sortTitle)
|
|
|
|
);
|
2024-03-13 05:34:47 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TableRowCell>
|
|
|
|
<span className={styles.commandName}>
|
|
|
|
{commandName}
|
2024-03-14 12:35:22 +00:00
|
|
|
{sortedSeries.length ? (
|
2024-04-25 19:59:00 +00:00
|
|
|
<span> - {formatTitles(sortedSeries.map((s) => s.title))}</span>
|
2024-03-13 05:34:47 +00:00
|
|
|
) : null}
|
|
|
|
{body.seasonNumber ? (
|
|
|
|
<span>
|
|
|
|
{' '}
|
|
|
|
{translate('SeasonNumberToken', {
|
|
|
|
seasonNumber: body.seasonNumber,
|
|
|
|
})}
|
|
|
|
</span>
|
|
|
|
) : null}
|
|
|
|
</span>
|
|
|
|
|
|
|
|
{clientUserAgent ? (
|
|
|
|
<span
|
|
|
|
className={styles.userAgent}
|
|
|
|
title={translate('TaskUserAgentTooltip')}
|
|
|
|
>
|
|
|
|
{translate('From')}: {clientUserAgent}
|
|
|
|
</span>
|
|
|
|
) : null}
|
|
|
|
</TableRowCell>
|
|
|
|
);
|
|
|
|
}
|