From 3369adfb9ad4283b17c83b62c4ca2a6ad3dae452 Mon Sep 17 00:00:00 2001 From: Brandon Cohen Date: Mon, 2 Oct 2023 13:18:31 -0400 Subject: [PATCH] fix: modified all instances of request button show state --- src/components/CollectionDetails/index.tsx | 21 +- src/components/Common/ListView/index.tsx | 2 + .../IssueModal/CreateIssueModal/index.tsx | 8 +- src/components/ManageSlideOver/index.tsx | 33 ++-- src/components/MovieDetails/index.tsx | 36 ++-- .../NotificationTypeSelector/index.tsx | 14 +- src/components/PersonDetails/index.tsx | 1 + src/components/RequestButton/index.tsx | 7 +- src/components/StatusBadge/index.tsx | 5 +- src/components/TvDetails/index.tsx | 182 +++++++++++------- 10 files changed, 195 insertions(+), 114 deletions(-) diff --git a/src/components/CollectionDetails/index.tsx b/src/components/CollectionDetails/index.tsx index ff22ee107..a180eac8c 100644 --- a/src/components/CollectionDetails/index.tsx +++ b/src/components/CollectionDetails/index.tsx @@ -129,6 +129,7 @@ const CollectionDetails = ({ collection }: CollectionDetailsProps) => { } const hasRequestable = + settings.currentSettings.movieEnabled && hasPermission([Permission.REQUEST, Permission.REQUEST_MOVIE], { type: 'or', }) && @@ -237,14 +238,19 @@ const CollectionDetails = ({ collection }: CollectionDetailsProps) => {
- (part.mediaInfo?.downloadStatus ?? []).length > 0 + {settings.currentSettings.movieEnabled && + hasPermission([Permission.REQUEST, Permission.REQUEST_MOVIE], { + type: 'or', + }) && ( + (part.mediaInfo?.downloadStatus ?? []).length > 0 + )} + /> )} - /> {settings.currentSettings.movie4kEnabled && hasPermission( [Permission.REQUEST_4K, Permission.REQUEST_4K_MOVIE], @@ -340,6 +346,7 @@ const CollectionDetails = ({ collection }: CollectionDetailsProps) => { id={title.id} image={title.posterPath} status={title.mediaInfo?.status} + status4k={title.mediaInfo?.status4k} summary={title.overview} title={title.title} userScore={title.voteAverage} diff --git a/src/components/Common/ListView/index.tsx b/src/components/Common/ListView/index.tsx index b46086862..35c3a2987 100644 --- a/src/components/Common/ListView/index.tsx +++ b/src/components/Common/ListView/index.tsx @@ -61,6 +61,7 @@ const ListView = ({ id={title.id} image={title.posterPath} status={title.mediaInfo?.status} + status4k={title.mediaInfo?.status4k} summary={title.overview} title={title.title} userScore={title.voteAverage} @@ -79,6 +80,7 @@ const ListView = ({ id={title.id} image={title.posterPath} status={title.mediaInfo?.status} + status4k={title.mediaInfo?.status4k} summary={title.overview} title={title.name} userScore={title.voteAverage} diff --git a/src/components/IssueModal/CreateIssueModal/index.tsx b/src/components/IssueModal/CreateIssueModal/index.tsx index 397322ca7..dd0e7c3ea 100644 --- a/src/components/IssueModal/CreateIssueModal/index.tsx +++ b/src/components/IssueModal/CreateIssueModal/index.tsx @@ -72,8 +72,12 @@ const CreateIssueModal = ({ const availableSeasons = (data?.mediaInfo?.seasons ?? []) .filter( (season) => - season.status === MediaStatus.AVAILABLE || - season.status === MediaStatus.PARTIALLY_AVAILABLE || + (settings.currentSettings.seriesEnabled && + hasPermission([Permission.REQUEST_4K, Permission.REQUEST_4K_TV], { + type: 'or', + }) && + (season.status === MediaStatus.AVAILABLE || + season.status === MediaStatus.PARTIALLY_AVAILABLE)) || (settings.currentSettings.series4kEnabled && hasPermission([Permission.REQUEST_4K, Permission.REQUEST_4K_TV], { type: 'or', diff --git a/src/components/ManageSlideOver/index.tsx b/src/components/ManageSlideOver/index.tsx index 103781d1c..4d7ee27be 100644 --- a/src/components/ManageSlideOver/index.tsx +++ b/src/components/ManageSlideOver/index.tsx @@ -468,22 +468,23 @@ const ManageSlideOver = ({ {intl.formatMessage(messages.manageModalAdvanced)}
- {data?.mediaInfo.status !== MediaStatus.AVAILABLE && ( - - )} + {data?.mediaInfo.status !== MediaStatus.AVAILABLE && + settings.currentSettings.seriesEnabled && ( + + )} {data?.mediaInfo.status4k !== MediaStatus.AVAILABLE && settings.currentSettings.series4kEnabled && (
- 0} - tmdbId={data.mediaInfo?.tmdbId} - mediaType="movie" - plexUrl={plexUrl} - serviceUrl={data.mediaInfo?.serviceUrl} - /> + {settings.currentSettings.movieEnabled && + hasPermission( + [ + Permission.MANAGE_REQUESTS, + Permission.REQUEST, + Permission.REQUEST_MOVIE, + ], + { + type: 'or', + } + ) && ( + 0} + tmdbId={data.mediaInfo?.tmdbId} + mediaType="movie" + plexUrl={plexUrl} + serviceUrl={data.mediaInfo?.serviceUrl} + /> + )} {settings.currentSettings.movie4kEnabled && hasPermission( [ @@ -379,7 +392,8 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => { tmdbId={data.id} onUpdate={() => revalidate()} /> - {(data.mediaInfo?.status === MediaStatus.AVAILABLE || + {((settings.currentSettings.movieEnabled && + data.mediaInfo?.status === MediaStatus.AVAILABLE) || (settings.currentSettings.movie4kEnabled && hasPermission( [Permission.REQUEST_4K, Permission.REQUEST_4K_MOVIE], diff --git a/src/components/NotificationTypeSelector/index.tsx b/src/components/NotificationTypeSelector/index.tsx index 149c2757a..868bf391f 100644 --- a/src/components/NotificationTypeSelector/index.tsx +++ b/src/components/NotificationTypeSelector/index.tsx @@ -159,17 +159,19 @@ const NotificationTypeSelector = ({ { type: 'or' } ) || // Cannot submit non-4K movie requests OR has Auto-Approve perms for non-4K movies - ((!hasPermission([Permission.REQUEST, Permission.REQUEST_MOVIE], { - type: 'or', - }) || + ((!settings.currentSettings.movieEnabled || + !hasPermission([Permission.REQUEST, Permission.REQUEST_MOVIE], { + type: 'or', + }) || hasPermission( [Permission.AUTO_APPROVE, Permission.AUTO_APPROVE_MOVIE], { type: 'or' } )) && // Cannot submit non-4K series requests OR has Auto-Approve perms for non-4K series - (!hasPermission([Permission.REQUEST, Permission.REQUEST_TV], { - type: 'or', - }) || + (!settings.currentSettings.seriesEnabled || + !hasPermission([Permission.REQUEST, Permission.REQUEST_TV], { + type: 'or', + }) || hasPermission( [Permission.AUTO_APPROVE, Permission.AUTO_APPROVE_TV], { type: 'or' } diff --git a/src/components/PersonDetails/index.tsx b/src/components/PersonDetails/index.tsx index 7d758679a..ef762aab2 100644 --- a/src/components/PersonDetails/index.tsx +++ b/src/components/PersonDetails/index.tsx @@ -145,6 +145,7 @@ const PersonDetails = () => { summary={media.overview} mediaType={media.mediaType as 'movie' | 'tv'} status={media.mediaInfo?.status} + status4k={media.mediaInfo?.status4k} canExpand /> {media.character && ( diff --git a/src/components/RequestButton/index.tsx b/src/components/RequestButton/index.tsx index 56e91810b..8e77b7875 100644 --- a/src/components/RequestButton/index.tsx +++ b/src/components/RequestButton/index.tsx @@ -273,7 +273,9 @@ const RequestButton = ({ : Permission.REQUEST_TV, ], { type: 'or' } - ) + ) && + ((settings.currentSettings.movieEnabled && mediaType === 'movie') || + (settings.currentSettings.seriesEnabled && mediaType === 'tv')) ) { buttons.push({ id: 'request', @@ -292,7 +294,8 @@ const RequestButton = ({ }) && media && media.status !== MediaStatus.AVAILABLE && - !isShowComplete + !isShowComplete && + settings.currentSettings.seriesEnabled ) { buttons.push({ id: 'request-more', diff --git a/src/components/StatusBadge/index.tsx b/src/components/StatusBadge/index.tsx index b60b7af04..0a025d1d4 100644 --- a/src/components/StatusBadge/index.tsx +++ b/src/components/StatusBadge/index.tsx @@ -73,7 +73,10 @@ const StatusBadge = ({ type: 'or', } ) && - (!is4k || + ((!is4k && + (mediaType === 'movie' + ? settings.currentSettings.movieEnabled + : settings.currentSettings.seriesEnabled)) || (mediaType === 'movie' ? settings.currentSettings.movie4kEnabled : settings.currentSettings.series4kEnabled)) diff --git a/src/components/TvDetails/index.tsx b/src/components/TvDetails/index.tsx index 2f44a7d8c..d5a4b7dd6 100644 --- a/src/components/TvDetails/index.tsx +++ b/src/components/TvDetails/index.tsx @@ -149,7 +149,13 @@ const TvDetails = ({ tv }: TvDetailsProps) => { const mediaLinks: PlayButtonLink[] = []; - if (plexUrl) { + if ( + settings.currentSettings.seriesEnabled && + plexUrl && + hasPermission([Permission.REQUEST, Permission.REQUEST_TV], { + type: 'or', + }) + ) { mediaLinks.push({ text: intl.formatMessage(messages.playonplex), url: plexUrl, @@ -337,16 +343,28 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
- 0} - tmdbId={data.mediaInfo?.tmdbId} - mediaType="tv" - plexUrl={plexUrl} - serviceUrl={data.mediaInfo?.serviceUrl} - /> + {settings.currentSettings.seriesEnabled && + hasPermission( + [ + Permission.MANAGE_REQUESTS, + Permission.REQUEST, + Permission.REQUEST_TV, + ], + { + type: 'or', + } + ) && ( + 0} + tmdbId={data.mediaInfo?.tmdbId} + mediaType="tv" + plexUrl={plexUrl} + serviceUrl={data.mediaInfo?.serviceUrl} + /> + )} {settings.currentSettings.series4kEnabled && hasPermission( [ @@ -404,8 +422,12 @@ const TvDetails = ({ tv }: TvDetailsProps) => { isShowComplete={isComplete} is4kShowComplete={is4kComplete} /> - {(data.mediaInfo?.status === MediaStatus.AVAILABLE || - data.mediaInfo?.status === MediaStatus.PARTIALLY_AVAILABLE || + {((settings.currentSettings.seriesEnabled && + hasPermission([Permission.REQUEST, Permission.REQUEST_TV], { + type: 'or', + }) && + (data.mediaInfo?.status === MediaStatus.AVAILABLE || + data?.mediaInfo?.status === MediaStatus.PARTIALLY_AVAILABLE)) || (settings.currentSettings.series4kEnabled && hasPermission([Permission.REQUEST_4K, Permission.REQUEST_4K_TV], { type: 'or', @@ -524,6 +546,18 @@ const TvDetails = ({ tv }: TvDetailsProps) => { .reverse() .filter((season) => season.seasonNumber !== 0) .map((season) => { + const showNon4k = + settings.currentSettings.seriesEnabled && + hasPermission( + [ + Permission.MANAGE_REQUESTS, + Permission.REQUEST, + Permission.REQUEST_TV, + ], + { + type: 'or', + } + ); const show4k = settings.currentSettings.series4kEnabled && hasPermission( @@ -588,65 +622,75 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
{((!mSeason && request?.status === MediaRequestStatus.APPROVED) || - mSeason?.status === MediaStatus.PROCESSING) && ( - <> -
- - {intl.formatMessage(globalMessages.requested)} - -
-
- -
- - )} + mSeason?.status === MediaStatus.PROCESSING) && + showNon4k && ( + <> +
+ + {intl.formatMessage( + globalMessages.requested + )} + +
+
+ +
+ + )} {((!mSeason && request?.status === MediaRequestStatus.PENDING) || - mSeason?.status === MediaStatus.PENDING) && ( - <> -
- - {intl.formatMessage(globalMessages.pending)} - -
-
- -
- - )} + mSeason?.status === MediaStatus.PENDING) && + showNon4k && ( + <> +
+ + {intl.formatMessage(globalMessages.pending)} + +
+
+ +
+ + )} {mSeason?.status === - MediaStatus.PARTIALLY_AVAILABLE && ( - <> -
- - {intl.formatMessage( - globalMessages.partiallyavailable - )} - -
-
- -
- - )} - {mSeason?.status === MediaStatus.AVAILABLE && ( - <> -
- - {intl.formatMessage(globalMessages.available)} - -
-
- -
- - )} + MediaStatus.PARTIALLY_AVAILABLE && + showNon4k && ( + <> +
+ + {intl.formatMessage( + globalMessages.partiallyavailable + )} + +
+
+ +
+ + )} + {mSeason?.status === MediaStatus.AVAILABLE && + showNon4k && ( + <> +
+ + {intl.formatMessage( + globalMessages.available + )} + +
+
+ +
+ + )} {((!mSeason4k && request4k?.status === MediaRequestStatus.APPROVED) ||