mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-18 21:35:27 -04:00
New: Info icon for Quality Profiles that are in use
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.deleteButtonInfoIcon {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.formatItemSmall {
|
||||
display: none;
|
||||
}
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// Please do not change this file!
|
||||
interface CssExports {
|
||||
'deleteButtonContainer': string;
|
||||
'deleteButtonInfoIcon': string;
|
||||
'formGroupWrapper': string;
|
||||
'formGroupsContainer': string;
|
||||
'formatItemLarge': string;
|
||||
|
||||
@@ -4,6 +4,7 @@ import Form from 'Components/Form/Form';
|
||||
import FormGroup from 'Components/Form/FormGroup';
|
||||
import FormInputGroup from 'Components/Form/FormInputGroup';
|
||||
import FormLabel from 'Components/Form/FormLabel';
|
||||
import Icon from 'Components/Icon';
|
||||
import Button from 'Components/Link/Button';
|
||||
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
|
||||
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||||
@@ -11,9 +12,10 @@ import ModalBody from 'Components/Modal/ModalBody';
|
||||
import ModalContent from 'Components/Modal/ModalContent';
|
||||
import ModalFooter from 'Components/Modal/ModalFooter';
|
||||
import ModalHeader from 'Components/Modal/ModalHeader';
|
||||
import Popover from 'Components/Tooltip/Popover';
|
||||
import useMeasure from 'Helpers/Hooks/useMeasure';
|
||||
import usePrevious from 'Helpers/Hooks/usePrevious';
|
||||
import { inputTypes, kinds, sizes } from 'Helpers/Props';
|
||||
import { icons, inputTypes, kinds, sizes } from 'Helpers/Props';
|
||||
import useQualityProfileInUse from 'Settings/Profiles/Quality/useQualityProfileInUse';
|
||||
import dimensions from 'Styles/Variables/dimensions';
|
||||
import { InputChanged } from 'typings/inputs';
|
||||
@@ -69,7 +71,8 @@ function EditQualityProfileModalContent({
|
||||
saveProvider,
|
||||
} = useManageQualityProfile(id, cloneId);
|
||||
|
||||
const isInUse = useQualityProfileInUse(id);
|
||||
const { seriesCount, importListCount } = useQualityProfileInUse(id);
|
||||
const isInUse = seriesCount !== 0 || importListCount !== 0;
|
||||
|
||||
const [measureHeaderRef, { height: headerHeight }] = useMeasure();
|
||||
const [measureBodyRef, { height: bodyHeight }] = useMeasure();
|
||||
@@ -699,6 +702,36 @@ function EditQualityProfileModalContent({
|
||||
>
|
||||
{translate('Delete')}
|
||||
</Button>
|
||||
|
||||
{isInUse ? (
|
||||
<Popover
|
||||
title={translate('QualityProfileUsage')}
|
||||
body={
|
||||
<div>
|
||||
{seriesCount ? (
|
||||
<div>
|
||||
{translate('QualityProfileUsedInCountSeries', {
|
||||
count: seriesCount,
|
||||
})}
|
||||
</div>
|
||||
) : null}
|
||||
{importListCount ? (
|
||||
<div>
|
||||
{translate('QualityProfileUsedInCountImportLists', {
|
||||
count: importListCount,
|
||||
})}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
}
|
||||
anchor={
|
||||
<Icon
|
||||
className={styles.deleteButtonInfoIcon}
|
||||
name={icons.INFO}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -11,13 +11,18 @@ function useQualityProfileInUse(id: number | undefined) {
|
||||
|
||||
return useMemo(() => {
|
||||
if (!id) {
|
||||
return false;
|
||||
return {
|
||||
seriesCount: 0,
|
||||
importsCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
series.some((s) => s.qualityProfileId === id) ||
|
||||
importLists.some((list) => list.qualityProfileId === id)
|
||||
);
|
||||
return {
|
||||
seriesCount: series.filter((s) => s.qualityProfileId === id).length,
|
||||
importListCount: importLists.filter(
|
||||
(list) => list.qualityProfileId === id
|
||||
).length,
|
||||
};
|
||||
}, [id, series, importLists]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1703,6 +1703,9 @@
|
||||
"QualityDefinitionsSizeNotice": "Size restrictions have been moved to Quality Profiles",
|
||||
"QualityProfile": "Quality Profile",
|
||||
"QualityProfileInUseSeriesListCollection": "Can't delete a quality profile that is attached to a series, list, or collection",
|
||||
"QualityProfileUsage": "Quality Profile Usage",
|
||||
"QualityProfileUsedInCountImportLists": "Used in {count} import lists",
|
||||
"QualityProfileUsedInCountSeries": "Used in {count} series",
|
||||
"QualityProfiles": "Quality Profiles",
|
||||
"QualityProfilesLoadError": "Unable to load Quality Profiles",
|
||||
"QualitySettings": "Quality Settings",
|
||||
|
||||
Reference in New Issue
Block a user