Skip to content

Commit

Permalink
fix(ui): disable request button in modal if no seasons to request
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCatLady committed Mar 16, 2021
1 parent 30ed841 commit c51e058
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/components/RequestModal/TvRequestModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const messages = defineMessages({
requestseasons:
'Request {seasonCount} {seasonCount, plural, one {Season} other {Seasons}}',
requestall: 'Request All Seasons',
alreadyrequested: 'Already Requested',
selectseason: 'Select Season(s)',
season: 'Season',
numberofepisodes: '# of Episodes',
Expand Down Expand Up @@ -345,7 +346,10 @@ const TvRequestModal: React.FC<RequestModalProps> = ({
editRequest && selectedSeasons.length === 0
? 'Cancel Request'
: !settings.currentSettings.partialRequestsEnabled
? intl.formatMessage(messages.requestall)
? getAllRequestedSeasons().length >=
(data?.mediaInfo?.seasons ?? []).length
? intl.formatMessage(messages.alreadyrequested)
: intl.formatMessage(messages.requestall)
: selectedSeasons.length === 0
? intl.formatMessage(messages.selectseason)
: intl.formatMessage(messages.requestseasons, {
Expand All @@ -355,8 +359,10 @@ const TvRequestModal: React.FC<RequestModalProps> = ({
okDisabled={
editRequest
? false
: settings.currentSettings.partialRequestsEnabled &&
selectedSeasons.length === 0
: getAllRequestedSeasons().length >=
(data?.mediaInfo?.seasons ?? []).length ||
(settings.currentSettings.partialRequestsEnabled &&
selectedSeasons.length === 0)
}
okButtonType={
editRequest &&
Expand Down Expand Up @@ -387,13 +393,16 @@ const TvRequestModal: React.FC<RequestModalProps> = ({
</svg>
}
>
{(hasPermission(Permission.MANAGE_REQUESTS) ||
hasPermission(
is4k ? Permission.AUTO_APPROVE_4K : Permission.AUTO_APPROVE
) ||
hasPermission(
is4k ? Permission.AUTO_APPROVE_4K_TV : Permission.AUTO_APPROVE_TV
)) &&
{hasPermission(
[
Permission.MANAGE_REQUESTS,
is4k ? Permission.AUTO_APPROVE_4K : Permission.AUTO_APPROVE,
is4k ? Permission.AUTO_APPROVE_4K_TV : Permission.AUTO_APPROVE_TV,
],
{ type: 'or' }
) &&
getAllRequestedSeasons().length <
(data?.mediaInfo?.seasons ?? []).length &&
!editRequest && (
<p className="mt-6">
<Alert
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"components.RequestModal.SearchByNameModal.nosummary": "No summary for this title was found.",
"components.RequestModal.SearchByNameModal.notvdbid": "Manual Match Required",
"components.RequestModal.SearchByNameModal.notvdbiddescription": "We couldn't automatically match your request. Please select the correct match from the list below:",
"components.RequestModal.alreadyrequested": "Already Requested",
"components.RequestModal.autoapproval": "Automatic Approval",
"components.RequestModal.backbutton": "Back",
"components.RequestModal.cancel": "Cancel Request",
Expand Down

0 comments on commit c51e058

Please sign in to comment.