From f90bef69342ca896dc1e55589dc9cd37b953f8ae Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 25 May 2023 00:36:07 +0300 Subject: [PATCH] Fix showing sorting values, add tooltips and translations to SeriesIndexPoster --- .../Index/Posters/SeriesIndexPoster.tsx | 47 ++++++++++---- .../Index/Posters/SeriesIndexPosterInfo.tsx | 63 ++++++++++++++++--- src/NzbDrone.Core/Localization/Core/en.json | 20 +++++- 3 files changed, 107 insertions(+), 23 deletions(-) diff --git a/frontend/src/Series/Index/Posters/SeriesIndexPoster.tsx b/frontend/src/Series/Index/Posters/SeriesIndexPoster.tsx index 351cab89b..162656766 100644 --- a/frontend/src/Series/Index/Posters/SeriesIndexPoster.tsx +++ b/frontend/src/Series/Index/Posters/SeriesIndexPoster.tsx @@ -14,7 +14,9 @@ import { Statistics } from 'Series/Series'; import SeriesPoster from 'Series/SeriesPoster'; import { executeCommand } from 'Store/Actions/commandActions'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import formatDateTime from 'Utilities/Date/formatDateTime'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import translate from 'Utilities/String/translate'; import createSeriesIndexItemSelector from '../createSeriesIndexItemSelector'; import selectPosterOptions from './selectPosterOptions'; import SeriesIndexPosterInfo from './SeriesIndexPosterInfo'; @@ -42,9 +44,8 @@ function SeriesIndexPoster(props: SeriesIndexPosterProps) { showSearchAction, } = useSelector(selectPosterOptions); - const { showRelativeDates, shortDateFormat, timeFormat } = useSelector( - createUISettingsSelector() - ); + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + useSelector(createUISettingsSelector()); const { title, @@ -52,7 +53,11 @@ function SeriesIndexPoster(props: SeriesIndexPosterProps) { status, path, titleSlug, + originalLanguage, + network, nextAiring, + previousAiring, + added, statistics = {} as Statistics, images, } = series; @@ -122,14 +127,14 @@ function SeriesIndexPoster(props: SeriesIndexPosterProps) { return (
-
+
{isSelectMode ? : null} {status === 'ended' ? ( -
+
) : null} @@ -185,20 +190,33 @@ function SeriesIndexPoster(props: SeriesIndexPosterProps) { isStandalone={false} /> - {showTitle ?
{title}
: null} + {showTitle ? ( +
+ {title} +
+ ) : null} {showMonitored ? (
- {monitored ? 'Monitored' : 'Unmonitored'} + {monitored ? translate('Monitored') : translate('Unmonitored')}
) : null} {showQualityProfile ? ( -
{qualityProfile.name}
+
+ {qualityProfile.name} +
) : null} {nextAiring ? ( -
+
{getRelativeDate(nextAiring, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true, @@ -207,6 +225,10 @@ function SeriesIndexPoster(props: SeriesIndexPosterProps) { ) : null} diff --git a/frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx b/frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx index be618cf4f..6cdfbcc14 100644 --- a/frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx +++ b/frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx @@ -1,10 +1,14 @@ import React from 'react'; +import Language from 'Language/Language'; import QualityProfile from 'typings/QualityProfile'; +import formatDateTime from 'Utilities/Date/formatDateTime'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './SeriesIndexPosterInfo.css'; interface SeriesIndexPosterInfoProps { + originalLanguage?: Language; network?: string; showQualityProfile: boolean; qualityProfile: QualityProfile; @@ -16,11 +20,13 @@ interface SeriesIndexPosterInfoProps { sortKey: string; showRelativeDates: boolean; shortDateFormat: string; + longDateFormat: string; timeFormat: string; } function SeriesIndexPosterInfo(props: SeriesIndexPosterInfoProps) { const { + originalLanguage, network, qualityProfile, showQualityProfile, @@ -32,20 +38,44 @@ function SeriesIndexPosterInfo(props: SeriesIndexPosterInfoProps) { sortKey, showRelativeDates, shortDateFormat, + longDateFormat, timeFormat, } = props; if (sortKey === 'network' && network) { - return
{network}
; + return ( +
+ {network} +
+ ); + } + + if (sortKey === 'originalLanguage' && !!originalLanguage?.name) { + return ( +
+ {originalLanguage.name} +
+ ); } if (sortKey === 'qualityProfileId' && !showQualityProfile) { - return
{qualityProfile.name}
; + return ( +
+ {qualityProfile.name} +
+ ); } if (sortKey === 'previousAiring' && previousAiring) { return ( -
+
{getRelativeDate(previousAiring, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true, @@ -65,27 +95,42 @@ function SeriesIndexPosterInfo(props: SeriesIndexPosterInfoProps) { } ); - return
{`Added ${addedDate}`}
; + return ( +
+ {translate('Added')}: {addedDate} +
+ ); } if (sortKey === 'seasonCount') { - let seasons = '1 season'; + let seasons = translate('OneSeason'); if (seasonCount === 0) { - seasons = 'No seasons'; + seasons = translate('NoSeasons'); } else if (seasonCount > 1) { - seasons = `${seasonCount} seasons`; + seasons = translate('CountSeasons', { count: seasonCount }); } return
{seasons}
; } if (sortKey === 'path') { - return
{path}
; + return ( +
+ {path} +
+ ); } if (sortKey === 'sizeOnDisk') { - return
{formatBytes(sizeOnDisk)}
; + return ( +
+ {formatBytes(sizeOnDisk)} +
+ ); } return null; diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index d71fc38a3..b04217e05 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -1,24 +1,40 @@ { + "Added": "Added", "ApplyChanges": "Apply Changes", "AutomaticAdd": "Automatic Add", "Browser Reload Required": "Browser Reload Required", + "CountSeasons": "{count} seasons", "EditSelectedDownloadClients": "Edit Selected Download Clients", "EditSelectedImportLists": "Edit Selected Import Lists", "EditSelectedIndexers": "Edit Selected Indexers", + "EditSeries": "Edit Series", "EnableAutomaticSearch": "Enable Automatic Search", - "Enabled": "Enabled", "EnableInteractiveSearch": "Enable Interactive Search", "EnableRss": "Enable Rss", + "Enabled": "Enabled", + "Ended": "Ended", "HiddenClickToShow": "Hidden, click to show", "HideAdvanced": "Hide Advanced", "Language": "Language", "Language that Sonarr will use for UI": "Language that Sonarr will use for UI", + "Monitored": "Monitored", + "Network": "Network", + "NextAiring": "Next Airing", + "NoSeasons": "No seasons", + "OneSeason": "1 season", + "OriginalLanguage": "Original Language", + "Path": "Path", + "PreviousAiring": "Previous Airing", "Priority": "Priority", "QualityProfile": "Quality Profile", + "RefreshSeries": "Refresh Series", "RemoveCompletedDownloads": "Remove Completed Downloads", "RemoveFailedDownloads": "Remove Failed Downloads", "RootFolder": "Root Folder", + "SearchForMonitoredEpisodes": "Search for monitored episodes", "ShowAdvanced": "Show Advanced", "ShownClickToHide": "Shown, click to hide", - "UI Language": "UI Language" + "SizeOnDisk": "Size on disk", + "UI Language": "UI Language", + "Unmonitored": "Unmonitored" }