mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-04 21:58:39 -05:00
fix: hide remove button when default service is not configured
This commit is contained in:
@@ -13,8 +13,10 @@ import { IssueStatus } from '../../../server/constants/issue';
|
|||||||
import {
|
import {
|
||||||
MediaRequestStatus,
|
MediaRequestStatus,
|
||||||
MediaStatus,
|
MediaStatus,
|
||||||
|
MediaType,
|
||||||
} from '../../../server/constants/media';
|
} from '../../../server/constants/media';
|
||||||
import { MediaWatchDataResponse } from '../../../server/interfaces/api/mediaInterfaces';
|
import { MediaWatchDataResponse } from '../../../server/interfaces/api/mediaInterfaces';
|
||||||
|
import { RadarrSettings, SonarrSettings } from '../../../server/lib/settings';
|
||||||
import { MovieDetails } from '../../../server/models/Movie';
|
import { MovieDetails } from '../../../server/models/Movie';
|
||||||
import { TvDetails } from '../../../server/models/Tv';
|
import { TvDetails } from '../../../server/models/Tv';
|
||||||
import useSettings from '../../hooks/useSettings';
|
import useSettings from '../../hooks/useSettings';
|
||||||
@@ -91,6 +93,12 @@ const ManageSlideOver: React.FC<
|
|||||||
? `/api/v1/media/${data.mediaInfo.id}/watch_data`
|
? `/api/v1/media/${data.mediaInfo.id}/watch_data`
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
const { data: radarrData } = useSWR<RadarrSettings[]>(
|
||||||
|
'/api/v1/settings/radarr'
|
||||||
|
);
|
||||||
|
const { data: sonarrData } = useSWR<SonarrSettings[]>(
|
||||||
|
'/api/v1/settings/sonarr'
|
||||||
|
);
|
||||||
|
|
||||||
const deleteMedia = async () => {
|
const deleteMedia = async () => {
|
||||||
if (data.mediaInfo) {
|
if (data.mediaInfo) {
|
||||||
@@ -106,6 +114,27 @@ const ManageSlideOver: React.FC<
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isDefaultService = () => {
|
||||||
|
if (data.mediaInfo) {
|
||||||
|
if (data.mediaInfo.mediaType === MediaType.MOVIE) {
|
||||||
|
return (
|
||||||
|
radarrData?.find(
|
||||||
|
(radarr) =>
|
||||||
|
radarr.isDefault && radarr.id === data.mediaInfo?.serviceId
|
||||||
|
) !== undefined
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
sonarrData?.find(
|
||||||
|
(sonarr) =>
|
||||||
|
sonarr.isDefault && sonarr.id === data.mediaInfo?.serviceId
|
||||||
|
) !== undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const markAvailable = async (is4k = false) => {
|
const markAvailable = async (is4k = false) => {
|
||||||
if (data.mediaInfo) {
|
if (data.mediaInfo) {
|
||||||
await axios.post(`/api/v1/media/${data.mediaInfo?.id}/available`, {
|
await axios.post(`/api/v1/media/${data.mediaInfo?.id}/available`, {
|
||||||
@@ -336,7 +365,8 @@ const ManageSlideOver: React.FC<
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{hasPermission(Permission.ADMIN) &&
|
{hasPermission(Permission.ADMIN) &&
|
||||||
data?.mediaInfo?.serviceUrl && (
|
data?.mediaInfo?.serviceUrl &&
|
||||||
|
isDefaultService() && (
|
||||||
<div>
|
<div>
|
||||||
<ConfirmButton
|
<ConfirmButton
|
||||||
onClick={() => deleteMediaFile()}
|
onClick={() => deleteMediaFile()}
|
||||||
@@ -482,35 +512,37 @@ const ManageSlideOver: React.FC<
|
|||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</a>
|
</a>
|
||||||
<div>
|
{isDefaultService() && (
|
||||||
<ConfirmButton
|
<div>
|
||||||
onClick={() => deleteMediaFile()}
|
<ConfirmButton
|
||||||
confirmText={intl.formatMessage(
|
onClick={() => deleteMediaFile()}
|
||||||
globalMessages.areyousure
|
confirmText={intl.formatMessage(
|
||||||
)}
|
globalMessages.areyousure
|
||||||
className="w-full"
|
)}
|
||||||
>
|
className="w-full"
|
||||||
<TrashIcon />
|
>
|
||||||
<span>
|
<TrashIcon />
|
||||||
{intl.formatMessage(messages.removearr4k, {
|
<span>
|
||||||
arr: mediaType === 'movie' ? 'Radarr' : 'Sonarr',
|
{intl.formatMessage(messages.removearr4k, {
|
||||||
})}
|
arr: mediaType === 'movie' ? 'Radarr' : 'Sonarr',
|
||||||
</span>
|
})}
|
||||||
</ConfirmButton>
|
</span>
|
||||||
<div className="mt-1 text-xs text-gray-400">
|
</ConfirmButton>
|
||||||
{intl.formatMessage(
|
<div className="mt-1 text-xs text-gray-400">
|
||||||
messages.manageModalRemoveMediaWarning,
|
{intl.formatMessage(
|
||||||
{
|
messages.manageModalRemoveMediaWarning,
|
||||||
mediaType: intl.formatMessage(
|
{
|
||||||
mediaType === 'movie'
|
mediaType: intl.formatMessage(
|
||||||
? messages.movie
|
mediaType === 'movie'
|
||||||
: messages.tvshow
|
? messages.movie
|
||||||
),
|
: messages.tvshow
|
||||||
arr: mediaType === 'movie' ? 'Radarr' : 'Sonarr',
|
),
|
||||||
}
|
arr: mediaType === 'movie' ? 'Radarr' : 'Sonarr',
|
||||||
)}
|
}
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user