1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #4920 from grafixeyehero/Fix-view-settings-button

Hide image type and year in certain views
This commit is contained in:
Bill Thornton 2023-11-29 17:17:07 -05:00 committed by GitHub
commit aa266c53b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,9 +16,16 @@ import Popover from '@mui/material/Popover';
import ViewComfyIcon from '@mui/icons-material/ViewComfy'; import ViewComfyIcon from '@mui/icons-material/ViewComfy';
import globalize from 'scripts/globalize'; import globalize from 'scripts/globalize';
import { LibraryViewSettings, ViewMode } from 'types/library'; import { LibraryViewSettings } from 'types/library';
import { LibraryTab } from 'types/libraryTab'; import { LibraryTab } from 'types/libraryTab';
const excludedViewType = [
LibraryTab.Episodes,
LibraryTab.Artists,
LibraryTab.AlbumArtists,
LibraryTab.Albums
];
const imageTypesOptions = [ const imageTypesOptions = [
{ label: 'Primary', value: ImageType.Primary }, { label: 'Primary', value: ImageType.Primary },
{ label: 'Banner', value: ImageType.Banner }, { label: 'Banner', value: ImageType.Banner },
@ -30,7 +37,9 @@ const imageTypesOptions = [
interface ViewSettingsButtonProps { interface ViewSettingsButtonProps {
viewType: LibraryTab; viewType: LibraryTab;
libraryViewSettings: LibraryViewSettings; libraryViewSettings: LibraryViewSettings;
setLibraryViewSettings: React.Dispatch<React.SetStateAction<LibraryViewSettings>>; setLibraryViewSettings: React.Dispatch<
React.SetStateAction<LibraryViewSettings>
>;
} }
const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
@ -72,27 +81,7 @@ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
[setLibraryViewSettings] [setLibraryViewSettings]
); );
const getVisibleImageType = () => { const isVisible = !excludedViewType.includes(viewType);
const visibleImageType: ImageType[] = [ImageType.Primary];
if (
viewType !== LibraryTab.Episodes
&& viewType !== LibraryTab.Artists
&& viewType !== LibraryTab.AlbumArtists
&& viewType !== LibraryTab.Albums
) {
visibleImageType.push(ImageType.Banner);
visibleImageType.push(ImageType.Disc);
visibleImageType.push(ImageType.Logo);
visibleImageType.push(ImageType.Thumb);
}
return visibleImageType;
};
const isViewSettingsEnabled = () => {
return libraryViewSettings.ViewMode !== ViewMode.ListView;
};
return ( return (
<Box> <Box>
@ -122,6 +111,7 @@ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
'& .MuiFormControl-root': { m: 1, width: 220 } '& .MuiFormControl-root': { m: 1, width: 220 }
}} }}
> >
{isVisible && (
<FormControl> <FormControl>
<InputLabel id='select-sort-label'> <InputLabel id='select-sort-label'>
<Typography component='span'> <Typography component='span'>
@ -133,9 +123,7 @@ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
label={globalize.translate('LabelImageType')} label={globalize.translate('LabelImageType')}
onChange={onSelectChange} onChange={onSelectChange}
> >
{imageTypesOptions {imageTypesOptions.map((imageType) => (
.filter((imageType) => getVisibleImageType().includes(imageType.value))
.map((imageType) => (
<MenuItem <MenuItem
key={imageType.value} key={imageType.value}
value={imageType.value} value={imageType.value}
@ -147,8 +135,7 @@ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
))} ))}
</Select> </Select>
</FormControl> </FormControl>
{isViewSettingsEnabled() && ( )}
<>
<Divider /> <Divider />
<FormControl> <FormControl>
<FormGroup> <FormGroup>
@ -162,6 +149,7 @@ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
} }
label={globalize.translate('ShowTitle')} label={globalize.translate('ShowTitle')}
/> />
{isVisible && (
<FormControlLabel <FormControlLabel
control={ control={
<Checkbox <Checkbox
@ -172,24 +160,19 @@ const ViewSettingsButton: FC<ViewSettingsButtonProps> = ({
} }
label={globalize.translate('ShowYear')} label={globalize.translate('ShowYear')}
/> />
)}
<FormControlLabel <FormControlLabel
control={ control={
<Checkbox <Checkbox
checked={ checked={libraryViewSettings.CardLayout}
libraryViewSettings.CardLayout
}
onChange={handleChange} onChange={handleChange}
name='CardLayout' name='CardLayout'
/> />
} }
label={globalize.translate( label={globalize.translate('EnableCardLayout')}
'EnableCardLayout'
)}
/> />
</FormGroup> </FormGroup>
</FormControl> </FormControl>
</>
)}
</Popover> </Popover>
</Box> </Box>
); );