Option to toggle fields in songs, albums & artists (#923)
* Add toggleColumns - Add logic for toggling columns - Add MenuComponent + useSelectedFields hook * Refactoring * eslint-fixes * Typo * skip menu in albumGridView * add omittedFields * Add toggling for playlists and albumSong * Refactoring * defaultProps - fix * Add toggling for PlaylistSongs * remove accidental console log * Refactoring for future compatibility * Hide ToggleMenu in albumGridView * Add TopBarComponent in ToggleFieldsMenu * Add defaultOff for useSelectedFields * Fix edge case * eslint fix * Refactoring * Add propType for forwardRef * Fix issues * add translation for grid and table * add translation for grid and table * Ignore menuBtn for spotify-ish and Ligera themes * hide bpm by default in playlistSongs * Add memoization * Default album view must be Grid Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import React, { useCallback, useMemo } from 'react'
|
||||
import {
|
||||
BulkActionsToolbar,
|
||||
ListToolbar,
|
||||
@@ -28,6 +28,7 @@ import { AlbumLinkField } from '../song/AlbumLinkField'
|
||||
import { playTracks } from '../actions'
|
||||
import PlaylistSongBulkActions from './PlaylistSongBulkActions'
|
||||
import { QualityInfo } from '../common/QualityInfo'
|
||||
import useSelectedFields from '../common/useSelectedFields'
|
||||
|
||||
const useStyles = makeStyles(
|
||||
(theme) => ({
|
||||
@@ -127,6 +128,26 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
||||
[playlistId, reorder, ids]
|
||||
)
|
||||
|
||||
const toggleableFields = useMemo(() => {
|
||||
return {
|
||||
trackNumber: isDesktop && <TextField source="id" label={'#'} />,
|
||||
title: <SongTitleField source="title" showTrackNumbers={false} />,
|
||||
album: isDesktop && <AlbumLinkField source="album" />,
|
||||
artist: isDesktop && <TextField source="artist" />,
|
||||
duration: (
|
||||
<DurationField source="duration" className={classes.draggable} />
|
||||
),
|
||||
quality: isDesktop && <QualityInfo source="quality" sortable={false} />,
|
||||
bpm: isDesktop && <NumberField source="bpm" />,
|
||||
}
|
||||
}, [isDesktop, classes.draggable])
|
||||
|
||||
const columns = useSelectedFields({
|
||||
resource: 'playlistTrack',
|
||||
columns: toggleableFields,
|
||||
defaultOff: ['bpm'],
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<ListToolbar
|
||||
@@ -161,13 +182,7 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
||||
contextAlwaysVisible={!isDesktop}
|
||||
classes={{ row: classes.row }}
|
||||
>
|
||||
{isDesktop && <TextField source="id" label={'#'} />}
|
||||
<SongTitleField source="title" showTrackNumbers={false} />
|
||||
{isDesktop && <AlbumLinkField source="album" />}
|
||||
{isDesktop && <TextField source="artist" />}
|
||||
<DurationField source="duration" className={classes.draggable} />
|
||||
{isDesktop && <QualityInfo source="quality" sortable={false} />}
|
||||
{isDesktop && <NumberField source="bpm" />}
|
||||
{columns}
|
||||
<SongContextMenu
|
||||
onAddToPlaylist={onAddToPlaylist}
|
||||
showLove={false}
|
||||
|
||||
Reference in New Issue
Block a user